BUG: Fix removal of read-only directories

Read-only directories must be given write permission before we can
remove files and subdirectories from them.
This commit is contained in:
Brad King 2009-05-13 10:30:33 -04:00
parent 33a1076b84
commit cecfce23a5
1 changed files with 13 additions and 0 deletions

View File

@ -2103,6 +2103,19 @@ bool SystemTools::RemoveFile(const char* source)
bool SystemTools::RemoveADirectory(const char* source) bool SystemTools::RemoveADirectory(const char* source)
{ {
// Add write permission to the directory so we can modify its
// content to remove files and directories from it.
mode_t mode;
if(SystemTools::GetPermissions(source, mode))
{
#if defined(_WIN32) && !defined(__CYGWIN__)
mode |= S_IWRITE;
#else
mode |= S_IWUSR;
#endif
SystemTools::SetPermissions(source, mode);
}
Directory dir; Directory dir;
dir.Load(source); dir.Load(source);
size_t fileNum; size_t fileNum;