summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCopier.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-10-06 16:48:15 (GMT)
committerBrad King <brad.king@kitware.com>2022-10-06 19:08:06 (GMT)
commit85f01a1ec2203187d4cd99c74136774059b89b35 (patch)
treed7089498349f0b70c66f6ca5ce2b7c0f504ee850 /Source/cmFileCopier.cxx
parentaba48bd6acbf564dcb5b831b26cc01743b5b5f71 (diff)
downloadCMake-85f01a1ec2203187d4cd99c74136774059b89b35.zip
CMake-85f01a1ec2203187d4cd99c74136774059b89b35.tar.gz
CMake-85f01a1ec2203187d4cd99c74136774059b89b35.tar.bz2
file(INSTALL): Improve formatting of symlink creation error
Avoid printing two error messages. Format paths without wrapping.
Diffstat (limited to 'Source/cmFileCopier.cxx')
-rw-r--r--Source/cmFileCopier.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
index 1667807..6ad7706 100644
--- a/Source/cmFileCopier.cxx
+++ b/Source/cmFileCopier.cxx
@@ -504,11 +504,12 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile,
cmSystemTools::RemoveFile(toFile);
cmSystemTools::MakeDirectory(toFilePath);
- if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot create symlink \"" << toFile
- << "\": " << cmSystemTools::GetLastSystemError() << ".";
- this->Status.SetError(e.str());
+ cmsys::Status status =
+ cmSystemTools::CreateSymlinkQuietly(symlinkTarget, toFile);
+ if (!status) {
+ std::string e = cmStrCat(this->Name, " cannot create symlink\n ",
+ toFile, "\nbecause: ", status.GetString());
+ this->Status.SetError(e);
return false;
}
}
@@ -557,12 +558,13 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile));
// Create the symlink.
- if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot duplicate symlink \"" << fromFile
- << "\" at \"" << toFile
- << "\": " << cmSystemTools::GetLastSystemError() << ".";
- this->Status.SetError(e.str());
+ cmsys::Status status =
+ cmSystemTools::CreateSymlinkQuietly(symlinkTarget, toFile);
+ if (!status) {
+ std::string e =
+ cmStrCat(this->Name, " cannot duplicate symlink\n ", fromFile,
+ "\nat\n ", toFile, "\nbecause: ", status.GetString());
+ this->Status.SetError(e);
return false;
}
}