Merge branch 'upstream-KWSys' into remove-write-only-dir

# By KWSys Upstream
* upstream-KWSys:
  KWSys 2023-11-29 (433f3d23)
This commit is contained in:
Brad King
2023-11-29 07:54:36 -05:00

View File

@@ -2794,14 +2794,14 @@ Status SystemTools::RemoveFile(std::string const& source)
Status SystemTools::RemoveADirectory(std::string const& source) Status SystemTools::RemoveADirectory(std::string const& source)
{ {
// Add write permission to the directory so we can modify its // Add read and write permission to the directory so we can read
// content to remove files and directories from it. // and modify its content to remove files and directories from it.
mode_t mode = 0; mode_t mode = 0;
if (SystemTools::GetPermissions(source, mode)) { if (SystemTools::GetPermissions(source, mode)) {
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
mode |= S_IWRITE; mode |= S_IREAD | S_IWRITE;
#else #else
mode |= S_IWUSR; mode |= S_IRUSR | S_IWUSR;
#endif #endif
SystemTools::SetPermissions(source, mode); SystemTools::SetPermissions(source, mode);
} }