summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx142
1 files changed, 71 insertions, 71 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index e79bc6c..9fabdc7 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -174,7 +174,7 @@ bool cmFileCommand
}
std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -205,7 +205,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
std::string e
= "attempted to write a file: " + fileName +
" into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -235,7 +235,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for writing.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
file << message;
@@ -295,7 +295,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for reading.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
@@ -359,7 +359,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
}
}
}
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
@@ -371,23 +371,23 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << args[0] << " requires a file name and output variable";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
if(hash.get())
{
- std::string out = hash->HashFile(args[1].c_str());
+ std::string out = hash->HashFile(args[1]);
if(!out.empty())
{
- this->Makefile->AddDefinition(args[2].c_str(), out.c_str());
+ this->Makefile->AddDefinition(args[2], out.c_str());
return true;
}
cmOStringStream e;
e << args[0] << " failed to read file \"" << args[1] << "\": "
<< cmSystemTools::GetLastSystemError();
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
}
return false;
#else
@@ -481,7 +481,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_INPUT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -494,7 +494,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_OUTPUT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -507,7 +507,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_COUNT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
limit_count = count;
@@ -521,7 +521,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LENGTH_MINIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
minlen = len;
@@ -535,7 +535,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LENGTH_MAXIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
maxlen = len;
@@ -548,7 +548,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option REGEX value \""
<< args[i] << "\" could not be compiled.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
have_regex = true;
@@ -559,7 +559,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS given unknown argument \""
<< args[i] << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -586,7 +586,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "STRINGS file \"" << fileName << "\" cannot be read.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -709,7 +709,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
}
// Save the output in a makefile variable.
- this->Makefile->AddDefinition(outVar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outVar, output.c_str());
return true;
}
@@ -844,7 +844,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
}
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
@@ -873,14 +873,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
{
std::string e = "attempted to create a directory: " + *cdir
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
if ( !cmSystemTools::MakeDirectory(cdir->c_str()) )
{
std::string error = "problem creating directory: " + *cdir;
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
}
@@ -926,7 +926,7 @@ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "DIFFERENT given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1041,7 +1041,7 @@ protected:
{
cmOStringStream e;
e << this->Name << " cannot set permissions on \"" << toFile << "\"";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -1065,7 +1065,7 @@ protected:
{
cmOStringStream e;
e << this->Name << " given invalid permission \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -1092,7 +1092,7 @@ protected:
// The input file does not exist and installation is not optional.
cmOStringStream e;
e << this->Name << " cannot find \"" << fromFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1125,14 +1125,14 @@ protected:
{
cmOStringStream e;
e << "option " << arg << " may not appear before PATTERN or REGEX.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
void NotAfterMatch(std::string const& arg)
{
cmOStringStream e;
e << "option " << arg << " may not appear after PATTERN or REGEX.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
virtual void DefaultFilePermissions()
@@ -1170,7 +1170,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "called with unknown argument \"" << args[i] << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1186,7 +1186,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
{
cmOStringStream e;
e << this->Name << " given no DESTINATION";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1366,7 +1366,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
{
cmOStringStream e;
e << "could not compile PATTERN \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
}
@@ -1382,7 +1382,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
{
cmOStringStream e;
e << "could not compile REGEX \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
break;
@@ -1462,7 +1462,7 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile)
{
cmOStringStream e;
e << "INSTALL encountered an empty string input file name.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1504,7 +1504,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
cmOStringStream e;
e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1537,7 +1537,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
cmOStringStream e;
e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
}
@@ -1569,7 +1569,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
cmOStringStream e;
e << this->Name << " cannot copy file \"" << fromFile
<< "\" to \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1588,7 +1588,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
cmOStringStream e;
e << this->Name << " cannot set modification time on \""
<< toFile << "\"";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
}
@@ -1619,7 +1619,7 @@ bool cmFileCopier::InstallDirectory(const char* source,
cmOStringStream e;
e << this->Name << " cannot make directory \"" << destination << "\": "
<< cmSystemTools::GetLastSystemError();
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1910,7 +1910,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
e << "INSTALL called with old-style " << arg << " argument. "
<< "This script was generated with an older version of CMake. "
<< "Re-run this cmake version on your build tree.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
else
@@ -1976,7 +1976,7 @@ bool cmFileInstaller
{
cmOStringStream e;
e << "Option TYPE given unknown value \"" << stype << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -2047,7 +2047,7 @@ bool cmFileInstaller::HandleInstallDestination()
"absolute path or remove DESTDIR environment variable."
"\nDESTINATION=\n";
message += destination;
- this->FileCommand->SetError(message.c_str());
+ this->FileCommand->SetError(message);
return false;
}
}
@@ -2061,7 +2061,7 @@ bool cmFileInstaller::HandleInstallDestination()
{
std::string errstring = "cannot create directory: " + destination +
". Maybe need administrative privileges.";
- this->FileCommand->SetError(errstring.c_str());
+ this->FileCommand->SetError(errstring);
return false;
}
}
@@ -2069,7 +2069,7 @@ bool cmFileInstaller::HandleInstallDestination()
{
std::string errstring = "INSTALL destination: " + destination +
" is not a directory.";
- this->FileCommand->SetError(errstring.c_str());
+ this->FileCommand->SetError(errstring);
return false;
}
return true;
@@ -2118,7 +2118,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHANGE given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2141,7 +2141,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
bool success = true;
@@ -2157,7 +2157,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
<< "to the file:\n"
<< " " << file << "\n"
<< emsg;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
success = false;
}
if(success)
@@ -2203,7 +2203,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_REMOVE given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2216,7 +2216,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
bool success = true;
@@ -2230,7 +2230,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
e << "RPATH_REMOVE could not remove RPATH from file:\n"
<< " " << file << "\n"
<< emsg;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
success = false;
}
if(success)
@@ -2284,7 +2284,7 @@ cmFileCommand::HandleRPathCheckCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHECK given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2337,7 +2337,7 @@ bool cmFileCommand::HandleRelativePathCommand(
std::string errstring =
"RELATIVE_PATH must be passed a full path to the directory: "
+ directoryName;
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
if(!cmSystemTools::FileIsFullPath(fileName.c_str()))
@@ -2345,13 +2345,13 @@ bool cmFileCommand::HandleRelativePathCommand(
std::string errstring =
"RELATIVE_PATH must be passed a full path to the file: "
+ fileName;
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
std::string res = cmSystemTools::RelativePath(directoryName.c_str(),
fileName.c_str());
- this->Makefile->AddDefinition(outVar.c_str(),
+ this->Makefile->AddDefinition(outVar,
res.c_str());
return true;
}
@@ -2389,7 +2389,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
<< "to\n"
<< " " << newname << "\n"
<< "because: " << err << "\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
return true;
@@ -2649,7 +2649,7 @@ namespace {
{ \
std::string e(errstr); \
e += ::curl_easy_strerror(result); \
- this->SetError(e.c_str()); \
+ this->SetError(e); \
return false; \
}
@@ -2785,7 +2785,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string err =
"DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
err += *i;
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
std::string algo = i->substr(0, pos);
@@ -2795,7 +2795,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo;
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
hashMatchMSG = algo + " hash";
@@ -2809,7 +2809,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if(cmSystemTools::FileExists(file.c_str()) && hash.get())
{
std::string msg;
- std::string actualHash = hash->HashFile(file.c_str());
+ std::string actualHash = hash->HashFile(file);
if(actualHash == expectedHash)
{
msg = "returning early; file already exists with expected ";
@@ -2819,7 +2819,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)0 << ";\"" << msg;
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
return true;
@@ -2828,14 +2828,14 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Make sure parent directory exists so we can write to the file
// as we receive downloaded bits from curl...
//
- std::string dir = cmSystemTools::GetFilenamePath(file.c_str());
+ std::string dir = cmSystemTools::GetFilenamePath(file);
if(!cmSystemTools::FileExists(dir.c_str()) &&
!cmSystemTools::MakeDirectory(dir.c_str()))
{
std::string errstring = "DOWNLOAD error: cannot create directory '"
+ dir + "' - Specify file by full path name and verify that you "
"have directory creation and file write privileges.";
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
@@ -2954,7 +2954,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
@@ -2969,7 +2969,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
//
if (hash.get())
{
- std::string actualHash = hash->HashFile(file.c_str());
+ std::string actualHash = hash->HashFile(file);
if (actualHash.size() == 0)
{
this->SetError("DOWNLOAD cannot compute hash on downloaded file");
@@ -2986,7 +2986,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
<< " status: [" << (int)res << ";\""
<< ::curl_easy_strerror(res) << "\"]" << std::endl
;
- this->SetError(oss.str().c_str());
+ this->SetError(oss.str());
return false;
}
}
@@ -3000,12 +3000,12 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if(verboseLog.size())
{
- this->Makefile->AddDefinition(verboseLog.c_str(),
+ this->Makefile->AddDefinition(verboseLog,
&*chunkDebug.begin());
}
}
- this->Makefile->AddDefinition(verboseLog.c_str(),
+ this->Makefile->AddDefinition(verboseLog,
&*chunkDebug.begin());
}
@@ -3102,7 +3102,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
std::string errStr = "UPLOAD cannot open file '";
errStr += filename + "' for reading.";
- this->SetError(errStr.c_str());
+ this->SetError(errStr);
return false;
}
@@ -3111,7 +3111,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
std::string errStr = "UPLOAD cannot stat file '";
errStr += filename + "'.";
- this->SetError(errStr.c_str());
+ this->SetError(errStr);
fclose(fin);
return false;
}
@@ -3217,7 +3217,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
@@ -3246,7 +3246,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
log += "\n";
}
- this->Makefile->AddDefinition(logVar.c_str(), log.c_str());
+ this->Makefile->AddDefinition(logVar, log.c_str());
}
return true;
@@ -3368,7 +3368,7 @@ bool cmFileCommand::HandleTimestampCommand(
{
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
}
@@ -3376,7 +3376,7 @@ bool cmFileCommand::HandleTimestampCommand(
cmTimestamp timestamp;
std::string result = timestamp.FileModificationTime(
filename.c_str(), formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str());
+ this->Makefile->AddDefinition(outputVariable, result.c_str());
return true;
}