summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-18 16:48:53 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-02-18 16:49:00 (GMT)
commitfe564f313106b0f955b570920c48f7543e363da0 (patch)
treeac6aa5bb52aa7c7c7a7eeebb3610e577419d5a48
parent77b537cc35f239a72ccd8cddab6a35d9625c3c20 (diff)
parentce59cabc70b407a82354174f085aea234f696eba (diff)
downloadCMake-fe564f313106b0f955b570920c48f7543e363da0.zip
CMake-fe564f313106b0f955b570920c48f7543e363da0.tar.gz
CMake-fe564f313106b0f955b570920c48f7543e363da0.tar.bz2
Merge topic 'update-kwsys' into release-3.17
ce59cabc70 KWSys: SystemTools: CopyFileIfDifferent: Fix endless recursion Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4361
-rw-r--r--Source/kwsys/SystemTools.cxx15
-rw-r--r--Source/kwsys/testSystemTools.cxx9
2 files changed, 18 insertions, 6 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 39873e6..d27081b 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -2186,12 +2186,15 @@ bool SystemTools::CopyFileIfDifferent(const std::string& source,
// FilesDiffer does not handle file to directory compare
if (SystemTools::FileIsDirectory(destination)) {
const std::string new_destination = FileInDir(source, destination);
- return SystemTools::CopyFileIfDifferent(source, new_destination);
- }
- // source and destination are files so do a copy if they
- // are different
- if (SystemTools::FilesDiffer(source, destination)) {
- return SystemTools::CopyFileAlways(source, destination);
+ if (!SystemTools::ComparePath(new_destination, destination)) {
+ return SystemTools::CopyFileIfDifferent(source, new_destination);
+ }
+ } else {
+ // 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;
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 1f3a15b..3f6eeb8 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -1074,6 +1074,15 @@ static bool CheckCopyFileIfDifferent()
}
}
+ if (!kwsys::SystemTools::MakeDirectory("dir_a") ||
+ !kwsys::SystemTools::MakeDirectory("dir_b")) {
+ return false;
+ }
+
+ if (!kwsys::SystemTools::CopyFileIfDifferent("dir_a/", "dir_b")) {
+ ret = false;
+ }
+
return ret;
}