From f98a691933c6faa9fb6098d9242d1081d616396e Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 30 Jan 2015 00:57:22 +0100 Subject: Windows Setup: implement removal of non-empty directories to avoid errors during uninstall. --- src/Setup/Setup.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/Setup') 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; } -- cgit v1.2.3