BUG: On windows allow removing of files that are read-only

This commit is contained in:
Andy Cedilnik 2005-02-16 16:03:21 -05:00
parent ea6547b6b3
commit a8c74a6b57
1 changed files with 17 additions and 1 deletions

View File

@ -1157,7 +1157,23 @@ kwsys_stl::string SystemTools::GetLastSystemError()
bool SystemTools::RemoveFile(const char* source)
{
return unlink(source) != 0 ? false : true;
#ifdef _WIN32
mode_t mode;
if ( !SystemTools::GetPermissions(source, mode) )
{
return false;
}
/* Win32 unlink is stupid --- it fails if the file is read-only */
SystemTools::SetPermissions(source, S_IWRITE);
#endif
bool res = unlink(source) != 0 ? false : true;
#ifdef _WIN32
if ( !res )
{
SystemTools::SetPermissions(source, mode);
}
#endif
return res;
}
bool SystemTools::RemoveADirectory(const char* source)