Commits

hoffman  committed 7a65cbe

ENH: move fix for read only file configure to branch

  • Participants
  • Parent commits 74da1c7
  • Branches CMake-2-0
  • Tags CMake-2-0-6

Comments (0)

Files changed (1)

File GCC_XML/KWSys/SystemTools.cxx

 
 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)