From ab91ab30654052d15a8a39952f86fdaf4d83a868 Mon Sep 17 00:00:00 2001
From: Andy Cedilnik <andy.cedilnik@kitware.com>
Date: Wed, 29 Sep 2004 11:18:07 -0400
Subject: [PATCH] ENH: When copy file, if the output file exits, delete it
 first

---
 SystemTools.cxx | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/SystemTools.cxx b/SystemTools.cxx
index 3968228..2e63bb2 100644
--- a/SystemTools.cxx
+++ b/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);
-- 
GitLab