Add WRITE_FILE command, which writes string to a file
This commit is contained in:
parent
e5a8887426
commit
92714311c9
|
@ -88,6 +88,7 @@
|
|||
#include "cmQTWrapCPPCommand.cxx"
|
||||
#include "cmQTWrapUICommand.cxx"
|
||||
#include "cmWrapExcludeFilesCommand.cxx"
|
||||
#include "cmWriteFileCommand.cxx"
|
||||
|
||||
// on regular builds add in the load command command
|
||||
// we do not add it in on the bootstrap because it
|
||||
|
@ -171,4 +172,5 @@ void GetPredefinedCommands(std::list<cmCommand*>& commands)
|
|||
commands.push_back(new cmQTWrapCPPCommand);
|
||||
commands.push_back(new cmQTWrapUICommand);
|
||||
commands.push_back(new cmWrapExcludeFilesCommand);
|
||||
commands.push_back(new cmWriteFileCommand);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/*=========================================================================
|
||||
|
||||
Program: Insight Segmentation & Registration Toolkit
|
||||
Module: $RCSfile$
|
||||
Language: C++
|
||||
Date: $Date$
|
||||
Version: $Revision$
|
||||
|
||||
Copyright (c) 2002 Insight Consortium. All rights reserved.
|
||||
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notices for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#include "cmWriteFileCommand.h"
|
||||
#include "cmCacheManager.h"
|
||||
|
||||
// cmLibraryCommand
|
||||
bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& argsIn)
|
||||
{
|
||||
if(argsIn.size() < 2 )
|
||||
{
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> args;
|
||||
cmSystemTools::ExpandListArguments(argsIn, args);
|
||||
std::string message;
|
||||
std::vector<std::string>::const_iterator i = args.begin();
|
||||
|
||||
bool send_error = false;
|
||||
std::string fileName = *i;
|
||||
i++;
|
||||
|
||||
for(;i != args.end(); ++i)
|
||||
{
|
||||
message += *i;
|
||||
}
|
||||
|
||||
std::ofstream file(fileName.c_str(), std::ios::app);
|
||||
if ( !file )
|
||||
{
|
||||
cmSystemTools::Error("Internal CMake error when trying to open file: ",
|
||||
fileName.c_str());
|
||||
return false;
|
||||
}
|
||||
file << message << endl;
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*=========================================================================
|
||||
|
||||
Program: Insight Segmentation & Registration Toolkit
|
||||
Module: $RCSfile$
|
||||
Language: C++
|
||||
Date: $Date$
|
||||
Version: $Revision$
|
||||
|
||||
Copyright (c) 2002 Insight Consortium. All rights reserved.
|
||||
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
|
||||
|
||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE. See the above copyright notices for more information.
|
||||
|
||||
=========================================================================*/
|
||||
#ifndef cmWriteFileCommand_h
|
||||
#define cmWriteFileCommand_h
|
||||
|
||||
#include "cmStandardIncludes.h"
|
||||
#include "cmCommand.h"
|
||||
|
||||
/** \class cmWriteFileCommand
|
||||
* \brief Writes a message to a file
|
||||
*
|
||||
*/
|
||||
class cmWriteFileCommand : public cmCommand
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
virtual cmCommand* Clone()
|
||||
{
|
||||
return new cmWriteFileCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when the command is first encountered in
|
||||
* the CMakeLists.txt file.
|
||||
*/
|
||||
virtual bool InitialPass(std::vector<std::string> const& args);
|
||||
|
||||
/**
|
||||
* The name of the command as specified in CMakeList.txt.
|
||||
*/
|
||||
virtual const char* GetName() { return "WRITE_FILE";}
|
||||
|
||||
/**
|
||||
* Succinct documentation.
|
||||
*/
|
||||
virtual const char* GetTerseDocumentation()
|
||||
{
|
||||
return "Write a message to a file.";
|
||||
}
|
||||
|
||||
/**
|
||||
* More documentation.
|
||||
*/
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
"WRITE_FILE(filename \"message to write\"...)\n"
|
||||
"The first argument is the file name, the rest of the arguments are messages to write.";
|
||||
}
|
||||
|
||||
cmTypeMacro(cmWriteFileCommand, cmCommand);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue