cmSystemTools: Return KWSys Status from CreateLink and CreateSymlink
This commit is contained in:
parent
27b5dc35a6
commit
7f89053953
@ -2949,9 +2949,11 @@ bool HandleCreateLinkCommand(std::vector<std::string> const& args,
|
||||
|
||||
// Check if the command requires a symbolic link.
|
||||
if (arguments.Symbolic) {
|
||||
completed = cmSystemTools::CreateSymlink(fileName, newFileName, &result);
|
||||
completed = static_cast<bool>(
|
||||
cmSystemTools::CreateSymlink(fileName, newFileName, &result));
|
||||
} else {
|
||||
completed = cmSystemTools::CreateLink(fileName, newFileName, &result);
|
||||
completed = static_cast<bool>(
|
||||
cmSystemTools::CreateLink(fileName, newFileName, &result));
|
||||
}
|
||||
|
||||
// Check if copy-on-error is enabled in the arguments.
|
||||
|
@ -3158,9 +3158,9 @@ std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes)
|
||||
return out;
|
||||
}
|
||||
|
||||
bool cmSystemTools::CreateSymlink(const std::string& origName,
|
||||
const std::string& newName,
|
||||
std::string* errorMessage)
|
||||
cmsys::Status cmSystemTools::CreateSymlink(std::string const& origName,
|
||||
std::string const& newName,
|
||||
std::string* errorMessage)
|
||||
{
|
||||
uv_fs_t req;
|
||||
int flags = 0;
|
||||
@ -3171,7 +3171,9 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
|
||||
#endif
|
||||
int err = uv_fs_symlink(nullptr, &req, origName.c_str(), newName.c_str(),
|
||||
flags, nullptr);
|
||||
cmsys::Status status;
|
||||
if (err) {
|
||||
status = cmsys::Status::POSIX(-err);
|
||||
std::string e =
|
||||
"failed to create symbolic link '" + newName + "': " + uv_strerror(err);
|
||||
if (errorMessage) {
|
||||
@ -3179,20 +3181,20 @@ bool cmSystemTools::CreateSymlink(const std::string& origName,
|
||||
} else {
|
||||
cmSystemTools::Error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return status;
|
||||
}
|
||||
|
||||
bool cmSystemTools::CreateLink(const std::string& origName,
|
||||
const std::string& newName,
|
||||
std::string* errorMessage)
|
||||
cmsys::Status cmSystemTools::CreateLink(std::string const& origName,
|
||||
std::string const& newName,
|
||||
std::string* errorMessage)
|
||||
{
|
||||
uv_fs_t req;
|
||||
int err =
|
||||
uv_fs_link(nullptr, &req, origName.c_str(), newName.c_str(), nullptr);
|
||||
cmsys::Status status;
|
||||
if (err) {
|
||||
status = cmsys::Status::POSIX(-err);
|
||||
std::string e =
|
||||
"failed to create link '" + newName + "': " + uv_strerror(err);
|
||||
if (errorMessage) {
|
||||
@ -3200,10 +3202,8 @@ bool cmSystemTools::CreateLink(const std::string& origName,
|
||||
} else {
|
||||
cmSystemTools::Error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return status;
|
||||
}
|
||||
|
||||
cm::string_view cmSystemTools::GetSystemName()
|
||||
|
@ -489,15 +489,15 @@ public:
|
||||
|
||||
/** Create a symbolic link if the platform supports it. Returns whether
|
||||
creation succeeded. */
|
||||
static bool CreateSymlink(const std::string& origName,
|
||||
const std::string& newName,
|
||||
std::string* errorMessage = nullptr);
|
||||
static cmsys::Status CreateSymlink(std::string const& origName,
|
||||
std::string const& newName,
|
||||
std::string* errorMessage = nullptr);
|
||||
|
||||
/** Create a hard link if the platform supports it. Returns whether
|
||||
creation succeeded. */
|
||||
static bool CreateLink(const std::string& origName,
|
||||
const std::string& newName,
|
||||
std::string* errorMessage = nullptr);
|
||||
static cmsys::Status CreateLink(std::string const& origName,
|
||||
std::string const& newName,
|
||||
std::string* errorMessage = nullptr);
|
||||
|
||||
/** Get the system name. */
|
||||
static cm::string_view GetSystemName();
|
||||
|
Loading…
Reference in New Issue
Block a user