[cmake-commits] hoffman committed SystemTools.cxx 1.187 1.188

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jan 30 11:32:35 EST 2007


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv18833

Modified Files:
	SystemTools.cxx 
Log Message:
ENH: allow copy if different from a file to a directory to work


Index: SystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemTools.cxx,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- SystemTools.cxx	16 Jan 2007 19:37:33 -0000	1.187
+++ SystemTools.cxx	30 Jan 2007 16:32:33 -0000	1.188
@@ -1507,10 +1507,33 @@
 bool SystemTools::CopyFileIfDifferent(const char* source,
                                       const char* destination)
 {
+  // special check for a destination that is a directory
+  // FilesDiffer does not handle file to directory compare
+  if(SystemTools::FileIsDirectory(destination))
+    {
+    kwsys_stl::string new_destination = destination;
+    SystemTools::ConvertToUnixSlashes(new_destination);
+    new_destination += '/';
+    kwsys_stl::string source_name = source;
+    new_destination += SystemTools::GetFilenameName(source_name);
+    if(SystemTools::FilesDiffer(source, new_destination.c_str()))
+      {
+      return SystemTools::CopyFileAlways(source, destination);
+      }
+    else
+      {
+      // the files are the same so the copy is done return
+      // true
+      return true;
+      }
+    }
+  // source and destination are files so do a copy if they
+  // are different
   if(SystemTools::FilesDiffer(source, destination))
     {
     return SystemTools::CopyFileAlways(source, destination);
     }
+  // at this point the files must be the same so return true
   return true;
 }
 
@@ -1599,7 +1622,6 @@
     {
     return true;
     }
-
   mode_t perm = 0;
   bool perms = SystemTools::GetPermissions(source, perm);
 
@@ -1694,7 +1716,7 @@
     }
   else if(statSource.st_size != statDestination.st_size)
     {
-    return false;
+   return false;
     }
   if ( perms )
     {



More information about the Cmake-commits mailing list