Skip to content

Commit

Permalink
fixed wipe of empty files
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Apr 6, 2017
1 parent 4fb8c3d commit 70b0af6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
drkns 06.04.2017 07:53:14 +0000 - build 4932

1. Не работал вайп пустых файлов.

drkns 05.04.2017 20:10:41 +0000 - build 4931

1. Уточнение 4928.
Expand Down
23 changes: 18 additions & 5 deletions far/delete.cpp
Expand Up @@ -220,15 +220,19 @@ static bool MoveToRecycleBinInternal(const string& Objects)
return !Result && !fop.fAnyOperationsAborted;
}

static bool WipeFile(const string& Name, int TotalPercent, bool& Cancel)
static bool WipeFileData(const string& Name, int TotalPercent, bool& Cancel)
{
if (!os::SetFileAttributes(Name, FILE_ATTRIBUTE_NORMAL))
return false;

os::fs::file_walker WipeFile;
if (!WipeFile.Open(Name, FILE_READ_DATA | FILE_WRITE_DATA, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_SEQUENTIAL_SCAN))
return false;

unsigned long long FileSize;
if (!WipeFile.GetSize(FileSize))
return false;

if (!FileSize)
return true; // nothing to do here

const DWORD BufSize=65536;
if (!WipeFile.InitWalk(BufSize))
return false;
Expand Down Expand Up @@ -280,7 +284,16 @@ static bool WipeFile(const string& Name, int TotalPercent, bool& Cancel)
if (!WipeFile.SetEnd())
return false;

WipeFile.Close();
return true;
}

static bool WipeFile(const string& Name, int TotalPercent, bool& Cancel)
{
if (!os::SetFileAttributes(Name, FILE_ATTRIBUTE_NORMAL))
return false;

if (!WipeFileData(Name, TotalPercent, Cancel))
return false;

string strTempName;
if (!FarMkTempEx(strTempName, nullptr, false))
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4931)m4_dnl
m4_define(BUILD,4932)m4_dnl

0 comments on commit 70b0af6

Please sign in to comment.