summaryrefslogtreecommitdiff
path: root/Source/cmWriteFileCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmWriteFileCommand.cxx')
-rw-r--r--Source/cmWriteFileCommand.cxx27
1 files changed, 14 insertions, 13 deletions
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index 49dbf1a191..34e21b2f22 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -4,22 +4,23 @@
#include "cmsys/FStream.hxx"
-#include "cmMakefile.h"
-#include "cmSystemTools.h"
#include "cm_sys_stat.h"
-class cmExecutionStatus;
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
// cmLibraryCommand
-bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmWriteFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string message;
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
std::string const& fileName = *i;
bool overwrite = true;
@@ -33,10 +34,10 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
}
}
- if (!this->Makefile->CanIWriteThisFile(fileName)) {
+ if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
std::string e =
"attempted to write a file: " + fileName + " into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -65,10 +66,10 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
cmsys::ofstream file(fileName.c_str(),
overwrite ? std::ios::out : std::ios::app);
if (!file) {
- std::string error = "Internal CMake error when trying to open file: ";
- error += fileName;
- error += " for writing.";
- this->SetError(error);
+ std::string error =
+ cmStrCat("Internal CMake error when trying to open file: ", fileName,
+ " for writing.");
+ status.SetError(error);
return false;
}
file << message << std::endl;