ENH: Add MAKE_DIRECTORY and modify documentation
This commit is contained in:
parent
cf9562694f
commit
d0964a349e
|
@ -43,6 +43,10 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args)
|
||||||
{
|
{
|
||||||
return this->HandleGlobCommand(args);
|
return this->HandleGlobCommand(args);
|
||||||
}
|
}
|
||||||
|
else if ( subCommand == "MAKE_DIRECTORY" )
|
||||||
|
{
|
||||||
|
return this->HandleMakeDirectoryCommand(args);
|
||||||
|
}
|
||||||
|
|
||||||
std::string e = "does not recognize sub-command "+subCommand;
|
std::string e = "does not recognize sub-command "+subCommand;
|
||||||
this->SetError(e.c_str());
|
this->SetError(e.c_str());
|
||||||
|
@ -175,3 +179,36 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args)
|
||||||
m_Makefile->AddDefinition(variable.c_str(), output.c_str());
|
m_Makefile->AddDefinition(variable.c_str(), output.c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmFileCommand::HandleMakeDirectoryCommand(std::vector<std::string> const& args)
|
||||||
|
{
|
||||||
|
if(args.size() < 2 )
|
||||||
|
{
|
||||||
|
this->SetError("called with incorrect number of arguments");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string>::const_iterator i = args.begin();
|
||||||
|
|
||||||
|
i++; // Get rid of subcommand
|
||||||
|
|
||||||
|
std::string expr;
|
||||||
|
for ( ; i != args.end(); ++i )
|
||||||
|
{
|
||||||
|
const std::string* cdir = &(*i);
|
||||||
|
if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
|
||||||
|
{
|
||||||
|
expr = m_Makefile->GetCurrentDirectory();
|
||||||
|
expr += "/" + *i;
|
||||||
|
cdir = &expr;
|
||||||
|
}
|
||||||
|
if ( !cmSystemTools::MakeDirectory(cdir->c_str()) )
|
||||||
|
{
|
||||||
|
std::string error = "problem creating directory: " + *cdir;
|
||||||
|
this->SetError(error.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -72,13 +72,20 @@ public:
|
||||||
" FILE(GLOB variable [globbing expressions]...)\n"
|
" FILE(GLOB variable [globbing expressions]...)\n"
|
||||||
"WRITE will write a message into a file called 'filename'. It "
|
"WRITE will write a message into a file called 'filename'. It "
|
||||||
"overwrites the file if it already exists, and creates the file "
|
"overwrites the file if it already exists, and creates the file "
|
||||||
"if it does not exists.\n\n"
|
"if it does not exists.\n"
|
||||||
"APPEND will write a message into a file same as WRITE, except "
|
"APPEND will write a message into a file same as WRITE, except "
|
||||||
"it will append it to the end of the file\n\n"
|
"it will append it to the end of the file\n"
|
||||||
"READ will read the content of a file and store it into the "
|
"READ will read the content of a file and store it into the "
|
||||||
"variable.\n\n"
|
"variable.\n"
|
||||||
"GLOB will generate a list of all files that match the expressions "
|
"GLOB will generate a list of all files that match the globbing "
|
||||||
"and store it into the variable.\n\n"; }
|
"expressions and store it into the variable. Globbing expressions "
|
||||||
|
"are similar to regular expressions, but much simpler..\n"
|
||||||
|
"Examples of globbing expressions:\n"
|
||||||
|
" *.cxx - match all files with extension cxx\n"
|
||||||
|
" *.vt? - match all files with extension vta, vtb, ... vtz\n"
|
||||||
|
" f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n"
|
||||||
|
"MAKE_DIRECTORY will create a directory at the specified location";
|
||||||
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmFileCommand, cmCommand);
|
cmTypeMacro(cmFileCommand, cmCommand);
|
||||||
|
|
||||||
|
@ -86,6 +93,7 @@ protected:
|
||||||
bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
|
bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
|
||||||
bool HandleReadCommand(std::vector<std::string> const& args);
|
bool HandleReadCommand(std::vector<std::string> const& args);
|
||||||
bool HandleGlobCommand(std::vector<std::string> const& args);
|
bool HandleGlobCommand(std::vector<std::string> const& args);
|
||||||
|
bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue