summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorRolf Eike Beer <eb@emlix.com>2019-09-09 07:09:48 (GMT)
committerRolf Eike Beer <eb@emlix.com>2019-09-09 08:30:25 (GMT)
commit5eaf1e1be289245267263536f5464e40d2a677c0 (patch)
treef65c38775baf0b195144513fd72e54a26a3e9563 /Source/cmSystemTools.cxx
parentd803d6b59f294b1bd1bd32beb75468399560be95 (diff)
downloadCMake-5eaf1e1be289245267263536f5464e40d2a677c0.zip
CMake-5eaf1e1be289245267263536f5464e40d2a677c0.tar.gz
CMake-5eaf1e1be289245267263536f5464e40d2a677c0.tar.bz2
cmSystemTools: introduce MoveFileIfDifferent()
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index b7287d9..074faa5 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -855,6 +855,18 @@ bool cmSystemTools::RenameFile(const std::string& oldname,
#endif
}
+void cmSystemTools::MoveFileIfDifferent(const std::string& source,
+ const std::string& destination)
+{
+ if (FilesDiffer(source, destination)) {
+ if (RenameFile(source, destination)) {
+ return;
+ }
+ CopyFileAlways(source, destination);
+ }
+ RemoveFile(source);
+}
+
std::string cmSystemTools::ComputeFileHash(const std::string& source,
cmCryptoHash::Algo algo)
{