win32/rmdir_r.cpp: Try with RemoveDirectory
All checks were successful
/ build (pull_request) Successful in 13m5s
All checks were successful
/ build (pull_request) Successful in 13m5s
SHFileOperation has been shown to fail when removing empty directories, even if the documentation does not document such behaviour. [1] Therefore, RemoveDirectoryA is used since it is meant for empty directories. [2] [1]: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shfileoperationa [2]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-removedirectorya
This commit is contained in:
parent
709f34eddc
commit
87ac21db8a
1 changed files with 9 additions and 2 deletions
|
@ -68,9 +68,16 @@ int portability::rmdir_r(const char *path)
|
|||
|
||||
if ((res = SHFileOperation(&op)))
|
||||
{
|
||||
fprintf(stderr, "%s: SHFileOperation failed with %#x\n", __func__, res);
|
||||
fprintf(stderr, "%s: SHFileOperation %s failed with %#x, "
|
||||
"trying with RemoveDirectory\n", __func__, path, res);
|
||||
|
||||
if (!RemoveDirectory(path))
|
||||
{
|
||||
fprintf(stderr, "%s: RemoveDirectory %s failed with %#jx\n",
|
||||
__func__, path, static_cast<intmax_t>(GetLastError()));
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else if (op.fAnyOperationsAborted)
|
||||
{
|
||||
fprintf(stderr, "%s: operation aborted\n", __func__);
|
||||
|
|
Loading…
Reference in a new issue