Add flag to WRITE_FILE to append
This commit is contained in:
parent
74eeb49d4c
commit
91bd207812
@ -30,14 +30,22 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& argsIn)
|
|||||||
std::vector<std::string>::const_iterator i = args.begin();
|
std::vector<std::string>::const_iterator i = args.begin();
|
||||||
|
|
||||||
std::string fileName = *i;
|
std::string fileName = *i;
|
||||||
|
bool overwrite = true;
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
for(;i != args.end(); ++i)
|
for(;i != args.end(); ++i)
|
||||||
{
|
{
|
||||||
message += *i;
|
if ( *i == "APPEND" )
|
||||||
|
{
|
||||||
|
overwrite = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message += *i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream file(fileName.c_str(), std::ios::app);
|
std::ofstream file(fileName.c_str(), overwrite?std::ios::out : std::ios::app);
|
||||||
if ( !file )
|
if ( !file )
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Internal CMake error when trying to open file: ",
|
cmSystemTools::Error("Internal CMake error when trying to open file: ",
|
||||||
|
@ -60,8 +60,10 @@ public:
|
|||||||
virtual const char* GetFullDocumentation()
|
virtual const char* GetFullDocumentation()
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
"WRITE_FILE(filename \"message to write\"...)\n"
|
"WRITE_FILE(filename \"message to write\"... [APPEND])\n"
|
||||||
"The first argument is the file name, the rest of the arguments are messages to write.";
|
"The first argument is the file name, the rest of the arguments are "
|
||||||
|
"messages to write. If the argument APPEND is specified, then "
|
||||||
|
"the message will be appended.";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmWriteFileCommand, cmCommand);
|
cmTypeMacro(cmWriteFileCommand, cmCommand);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user