[CMD] RMDIR: Force directory deletion even if it's read-only, only when recursing over subdirectories (via the /S option).

This commit is contained in:
Hermès Bélusca-Maïto 2020-07-11 20:34:18 +02:00
parent 7c175d4999
commit 2f9b4a2e9f
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -408,6 +408,7 @@ BOOL DeleteFolder(LPTSTR FileName)
}
else
{
/* Force file deletion */
SetFileAttributes(TempFileName, FILE_ATTRIBUTE_NORMAL);
if (!DeleteFile(TempFileName))
{
@ -420,6 +421,8 @@ BOOL DeleteFolder(LPTSTR FileName)
FindClose(hFile);
}
/* Force directory deletion even if it's read-only */
SetFileAttributes(FileName, FILE_ATTRIBUTE_NORMAL);
return RemoveDirectory(FileName);
}
@ -506,6 +509,7 @@ INT cmd_rmdir(LPTSTR param)
}
else
{
/* Without /S, do not force directory deletion even if it's read-only */
res = RemoveDirectory(arg[i]);
}