cmSystemTools: Revise MoveFileIfDifferent to return cmsys::Status
Help callers recover errors without relying on global state.
This commit is contained in:
parent
0a0a826b86
commit
dc38f81237
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user