VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Setup
diff options
context:
space:
mode:
Diffstat (limited to 'src/Setup')
-rw-r--r--src/Setup/Setup.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index 0e404431..9f5fbfdd 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -101,7 +101,25 @@ BOOL StatRemoveDirectory (char *lpszDir)
struct __stat64 st;
if (_stat64 (lpszDir, &st) == 0)
- return RemoveDirectory (lpszDir);
+ {
+ BOOL bStatus = RemoveDirectory (lpszDir);
+ if (!bStatus)
+ {
+ /* force removal of the non empty directory */
+ char szOpPath[TC_MAX_PATH + 1] = {0};
+ SHFILEOPSTRUCTA op;
+
+ StringCbCopyA(szOpPath, sizeof(szOpPath)-1, lpszDir);
+ ZeroMemory(&op, sizeof(op));
+ op.wFunc = FO_DELETE;
+ op.pFrom = szOpPath;
+ op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
+
+ if ((0 == SHFileOperation(&op)) && (!op.fAnyOperationsAborted))
+ bStatus = TRUE;
+ }
+ return bStatus;
+ }
else
return TRUE;
}