diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-16 21:03:21 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-02-16 21:03:21 (GMT) |
commit | a8c74a6b57be8b7b14f51e605eb7db731a19f62e (patch) | |
tree | 64f0e698c9639dc5ed187bfe9e0d6e5edfa3e07e | |
parent | ea6547b6b3921b1fc376b8c56b94704acf796296 (diff) | |
download | CMake-a8c74a6b57be8b7b14f51e605eb7db731a19f62e.zip CMake-a8c74a6b57be8b7b14f51e605eb7db731a19f62e.tar.gz CMake-a8c74a6b57be8b7b14f51e605eb7db731a19f62e.tar.bz2 |
BUG: On windows allow removing of files that are read-only
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 53f2a36..5968bd6 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -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) |