Windows Setup: implement removal of non-empty directories to avoid errors during uninstall.

This commit is contained in:
Mounir IDRASSI 2015-01-30 00:57:22 +01:00
parent 35497f87a7
commit f98a691933

View File

@ -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;
}