summaryrefslogtreecommitdiffstats
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx41
1 files changed, 24 insertions, 17 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 6713cc3..928435e 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -74,7 +74,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string>::const_iterator argEnd);
namespace {
-void CMakeCommandUsage(const char* program)
+void CMakeCommandUsage(std::string const& program)
{
std::ostringstream errorStream;
@@ -704,7 +704,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
} else if (args[2] == "--ignore-eol") {
filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]);
} else {
- CMakeCommandUsage(args[0].c_str());
+ CMakeCommandUsage(args[0]);
return 2;
}
@@ -1085,7 +1085,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
std::string const& directory = args[2];
if (!cmSystemTools::FileExists(directory)) {
cmSystemTools::Error("Directory does not exist for chdir command: " +
- args[2]);
+ directory);
return 1;
}
@@ -1152,7 +1152,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
<< "\n";
return 1;
}
- if (!cmSystemTools::CreateSymlink(args[2], args[3])) {
+ if (!cmSystemTools::CreateSymlink(args[2], destinationFileName)) {
return 1;
}
return 0;
@@ -1161,12 +1161,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
// Command to create a hard link. Fails on platforms not
// supporting them.
if (args[1] == "create_hardlink" && args.size() == 4) {
- const char* SouceFileName = args[2].c_str();
- const char* destinationFileName = args[3].c_str();
+ std::string const& sourceFileName = args[2];
+ std::string const& destinationFileName = args[3];
- if (!cmSystemTools::FileExists(SouceFileName)) {
+ if (!cmSystemTools::FileExists(sourceFileName)) {
std::cerr << "failed to create hard link because source path '"
- << SouceFileName << "' does not exist \n";
+ << sourceFileName << "' does not exist \n";
return 1;
}
@@ -1180,7 +1180,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
return 1;
}
- if (!cmSystemTools::CreateLink(args[2], args[3])) {
+ if (!cmSystemTools::CreateLink(sourceFileName, destinationFileName)) {
return 1;
}
return 0;
@@ -1560,7 +1560,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
}
}
- CMakeCommandUsage(args[0].c_str());
+ CMakeCommandUsage(args[0]);
return 1;
}
@@ -1601,14 +1601,18 @@ int cmcmd::SymlinkLibrary(std::vector<std::string> const& args)
cmSystemTools::ConvertToUnixSlashes(soName);
cmSystemTools::ConvertToUnixSlashes(name);
if (soName != realName) {
- if (!cmcmd::SymlinkInternal(realName, soName)) {
- cmSystemTools::ReportLastSystemError("cmake_symlink_library");
+ cmsys::Status status = cmcmd::SymlinkInternal(realName, soName);
+ if (!status) {
+ cmSystemTools::Error(
+ cmStrCat("cmake_symlink_library: System Error: ", status.GetString()));
result = 1;
}
}
if (name != soName) {
- if (!cmcmd::SymlinkInternal(soName, name)) {
- cmSystemTools::ReportLastSystemError("cmake_symlink_library");
+ cmsys::Status status = cmcmd::SymlinkInternal(soName, name);
+ if (!status) {
+ cmSystemTools::Error(
+ cmStrCat("cmake_symlink_library: System Error: ", status.GetString()));
result = 1;
}
}
@@ -1621,15 +1625,18 @@ int cmcmd::SymlinkExecutable(std::vector<std::string> const& args)
std::string const& realName = args[2];
std::string const& name = args[3];
if (name != realName) {
- if (!cmcmd::SymlinkInternal(realName, name)) {
- cmSystemTools::ReportLastSystemError("cmake_symlink_executable");
+ cmsys::Status status = cmcmd::SymlinkInternal(realName, name);
+ if (!status) {
+ cmSystemTools::Error(cmStrCat("cmake_symlink_executable: System Error: ",
+ status.GetString()));
result = 1;
}
}
return result;
}
-bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
+cmsys::Status cmcmd::SymlinkInternal(std::string const& file,
+ std::string const& link)
{
if (cmSystemTools::FileExists(link) || cmSystemTools::FileIsSymlink(link)) {
cmSystemTools::RemoveFile(link);