浏览代码

ENH: When copy file, if the output file exits, delete it first

Andy Cedilnik 21 年之前
父节点
当前提交
1852a88fa1
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      Source/kwsys/SystemTools.cxx

+ 5 - 0
Source/kwsys/SystemTools.cxx

@@ -967,6 +967,11 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
     return false;
     }
 
+  if ( SystemTools::FileExists(destination) && !SystemTools::RemoveFile(destination) )
+    {
+    return false;
+    }
+
 #if defined(_WIN32) || defined(__CYGWIN__)
   kwsys_ios::ofstream fout(destination, 
                      kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc);