mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-19 12:50:48 -05: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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmSystemTools::MoveFileIfDifferent(const std::string& source,
|
cmsys::Status cmSystemTools::MoveFileIfDifferent(
|
||||||
const std::string& destination)
|
const std::string& source, const std::string& destination)
|
||||||
{
|
{
|
||||||
|
cmsys::Status res = {};
|
||||||
if (FilesDiffer(source, destination)) {
|
if (FilesDiffer(source, destination)) {
|
||||||
if (RenameFile(source, destination)) {
|
if (RenameFile(source, destination)) {
|
||||||
return;
|
return res;
|
||||||
}
|
}
|
||||||
CopyFileAlways(source, destination);
|
res = CopyFileAlways(source, destination);
|
||||||
}
|
}
|
||||||
RemoveFile(source);
|
RemoveFile(source);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmSystemTools::Glob(const std::string& directory,
|
void cmSystemTools::Glob(const std::string& directory,
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ public:
|
|||||||
std::string* err = nullptr);
|
std::string* err = nullptr);
|
||||||
|
|
||||||
//! Rename a file if contents are different, delete the source otherwise
|
//! Rename a file if contents are different, delete the source otherwise
|
||||||
static void MoveFileIfDifferent(const std::string& source,
|
static cmsys::Status MoveFileIfDifferent(const std::string& source,
|
||||||
const std::string& destination);
|
const std::string& destination);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run a single executable command
|
* Run a single executable command
|
||||||
|
|||||||
Reference in New Issue
Block a user