summaryrefslogtreecommitdiffstats
path: root/Source/kwsys
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2007-01-30 16:32:33 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2007-01-30 16:32:33 (GMT)
commitb32f3b4131294b0d4d8895cecf3bb2df11ff434c (patch)
tree89ce3fd77f6137e75a2d9ecb41f5a6b8aed3704b /Source/kwsys
parent88f798d28659f27f17953b75341f1df753ec2acb (diff)
downloadCMake-b32f3b4131294b0d4d8895cecf3bb2df11ff434c.zip
CMake-b32f3b4131294b0d4d8895cecf3bb2df11ff434c.tar.gz
CMake-b32f3b4131294b0d4d8895cecf3bb2df11ff434c.tar.bz2
ENH: allow copy if different from a file to a directory to work
Diffstat (limited to 'Source/kwsys')
-rw-r--r--Source/kwsys/SystemTools.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index b6fabc7..8df1a65 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 )
{