mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 15:20:56 -06:00
cmSystemTools: introduce MoveFileIfDifferent()
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -131,6 +131,10 @@ public:
|
||||
static bool RenameFile(const std::string& oldname,
|
||||
const std::string& newname);
|
||||
|
||||
//! Rename a file if contents are different, delete the source otherwise
|
||||
static void MoveFileIfDifferent(const std::string& source,
|
||||
const std::string& destination);
|
||||
|
||||
//! Compute the hash of a file
|
||||
static std::string ComputeFileHash(const std::string& source,
|
||||
cmCryptoHash::Algo algo);
|
||||
|
||||
Reference in New Issue
Block a user