From b32f3b4131294b0d4d8895cecf3bb2df11ff434c Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 30 Jan 2007 11:32:33 -0500 Subject: [PATCH] ENH: allow copy if different from a file to a directory to work --- Source/kwsys/SystemTools.cxx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index b6fabc74d..8df1a65a6 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1507,10 +1507,33 @@ kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path) 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 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) { return true; } - mode_t perm = 0; bool perms = SystemTools::GetPermissions(source, perm); @@ -1694,7 +1716,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) } else if(statSource.st_size != statDestination.st_size) { - return false; + return false; } if ( perms ) {