summaryrefslogtreecommitdiff
path: root/Source/cmUseMangledMesaCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmUseMangledMesaCommand.cxx')
-rw-r--r--Source/cmUseMangledMesaCommand.cxx48
1 files changed, 23 insertions, 25 deletions
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 43581947c..1fd386bda 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -5,29 +5,30 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
+#include "cmExecutionStatus.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+namespace {
+void CopyAndFullPathMesaHeader(const std::string& source,
+ const std::string& outdir);
+}
-bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmUseMangledMesaCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// expected two arguments:
// argument one: the full path to gl_mangle.h
// argument two : directory for output of edited headers
if (args.size() != 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
const std::string& inputDir = args[0];
- std::string glh = inputDir;
- glh += "/";
- glh += "gl.h";
+ std::string glh = cmStrCat(inputDir, "/gl.h");
if (!cmSystemTools::FileExists(glh)) {
- std::string e = "Bad path to Mesa, could not find: ";
- e += glh;
- e += " ";
- this->SetError(e);
+ std::string e = cmStrCat("Bad path to Mesa, could not find: ", glh, ' ');
+ status.SetError(e);
return false;
}
const std::string& destDir = args[1];
@@ -39,25 +40,22 @@ bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
}
cmSystemTools::MakeDirectory(destDir);
for (std::string const& f : files) {
- std::string path = inputDir;
- path += "/";
- path += f;
- this->CopyAndFullPathMesaHeader(path, destDir);
+ std::string path = cmStrCat(inputDir, '/', f);
+ CopyAndFullPathMesaHeader(path, destDir);
}
return true;
}
-void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(
- const std::string& source, const std::string& outdir)
+namespace {
+void CopyAndFullPathMesaHeader(const std::string& source,
+ const std::string& outdir)
{
- std::string dir, file;
+ std::string dir;
+ std::string file;
cmSystemTools::SplitProgramPath(source, dir, file);
- std::string outFile = outdir;
- outFile += "/";
- outFile += file;
- std::string tempOutputFile = outFile;
- tempOutputFile += ".tmp";
+ std::string outFile = cmStrCat(outdir, '/', file);
+ std::string tempOutputFile = cmStrCat(outFile, ".tmp");
cmsys::ofstream fout(tempOutputFile.c_str());
if (!fout) {
cmSystemTools::Error("Could not open file for write in copy operation: " +
@@ -100,6 +98,6 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(
// close the files before attempting to copy
fin.close();
fout.close();
- cmSystemTools::CopyFileIfDifferent(tempOutputFile, outFile);
- cmSystemTools::RemoveFile(tempOutputFile);
+ cmSystemTools::MoveFileIfDifferent(tempOutputFile, outFile);
+}
}