diff options
author | Rolf Eike Beer <eb@emlix.com> | 2019-09-09 08:34:08 (GMT) |
---|---|---|
committer | Rolf Eike Beer <eb@emlix.com> | 2019-09-09 08:34:08 (GMT) |
commit | 5b96fd5b81bde4655e471a31bf0fc579c1d10136 (patch) | |
tree | 13d9a3b24d84e1d15c4e1929c6c6224ae126675f | |
parent | 5eaf1e1be289245267263536f5464e40d2a677c0 (diff) | |
download | CMake-5b96fd5b81bde4655e471a31bf0fc579c1d10136.zip CMake-5b96fd5b81bde4655e471a31bf0fc579c1d10136.tar.gz CMake-5b96fd5b81bde4655e471a31bf0fc579c1d10136.tar.bz2 |
use cmSystemTools::MoveFileIfDifferent()
This is better than doing CopyFileIfDifferent() followed by RemoveFile() in
two ways:
- it is more efficient, as it avoids disk I/O for the data, even if the
files here are usually small
- it is atomic, so an abort during the copy will not leave a destination file
with partial data behind
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmUseMangledMesaCommand.cxx | 3 |
3 files changed, 4 insertions, 8 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b4706a3..f1c48cc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3417,8 +3417,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, file << pchEpilogue << "\n"; } } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } return inserted.first->second; } @@ -3451,8 +3450,7 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config, cmGeneratedFileStream file(filename_tmp); file << "/* generated by CMake */\n"; } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); } return inserted.first->second; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9152e94..3d8c3fb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2275,8 +2275,7 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target, } } } - cmSystemTools::CopyFileIfDifferent(filename_tmp, filename); - cmSystemTools::RemoveFile(filename_tmp); + cmSystemTools::MoveFileIfDifferent(filename_tmp, filename); target->AddSource(filename, true); diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx index cfc00e8..1fd386b 100644 --- a/Source/cmUseMangledMesaCommand.cxx +++ b/Source/cmUseMangledMesaCommand.cxx @@ -98,7 +98,6 @@ void CopyAndFullPathMesaHeader(const std::string& source, // close the files before attempting to copy fin.close(); fout.close(); - cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile); - cmSystemTools::RemoveFile(tempOutputFile); + cmSystemTools::MoveFileIfDifferent(tempOutputFile, outFile); } } |