mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-12 09:20:41 -06:00
cmSystemTools: Revise MoveFileIfDifferent to return cmsys::Status
Help callers recover errors without relying on global state.
This commit is contained in:
@@ -1319,16 +1319,18 @@ cmSystemTools::RenameResult cmSystemTools::RenameFile(
|
||||
#endif
|
||||
}
|
||||
|
||||
void cmSystemTools::MoveFileIfDifferent(const std::string& source,
|
||||
const std::string& destination)
|
||||
cmsys::Status cmSystemTools::MoveFileIfDifferent(
|
||||
const std::string& source, const std::string& destination)
|
||||
{
|
||||
cmsys::Status res = {};
|
||||
if (FilesDiffer(source, destination)) {
|
||||
if (RenameFile(source, destination)) {
|
||||
return;
|
||||
return res;
|
||||
}
|
||||
CopyFileAlways(source, destination);
|
||||
res = CopyFileAlways(source, destination);
|
||||
}
|
||||
RemoveFile(source);
|
||||
return res;
|
||||
}
|
||||
|
||||
void cmSystemTools::Glob(const std::string& directory,
|
||||
|
||||
@@ -211,8 +211,8 @@ public:
|
||||
std::string* err = nullptr);
|
||||
|
||||
//! Rename a file if contents are different, delete the source otherwise
|
||||
static void MoveFileIfDifferent(const std::string& source,
|
||||
const std::string& destination);
|
||||
static cmsys::Status MoveFileIfDifferent(const std::string& source,
|
||||
const std::string& destination);
|
||||
|
||||
/**
|
||||
* Run a single executable command
|
||||
|
||||
Reference in New Issue
Block a user