39 parser.
setExampleLongOption(
"phoenix_srcsplittexdir --input=fileInput.cpp --output=output.ptex --platex");
44 PPath defaultOutputDir(
"./");
45 parser.
addOption(
"output",
"o", defaultOutputDir,
"output directory for generated files and directories");
49 parser.
addOption(
"removefirstcomment",
"f",
OptionType::NONE,
false,
"remove the first comment of the file (can be the Licence or whatever)");
68 std::cerr <<
"createDirectoryWithFiles : Can't create directory '" << currentOutputDir <<
"'" << std::endl;
71 for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
84 for(PVecPath::const_iterator itPath(vecPath.begin()); itPath != vecPath.end(); ++itPath){
86 PVecPath::const_iterator it(listIgnoreDir.begin());
87 while(it != listIgnoreDir.end() && !isFound){
88 isFound = itPath->getFileName() == *it;
92 vecOut.push_back(*itPath);
106 std::cout <<
"createFileFunctionGenerator : begin '" << inputFile <<
"'" << std::endl;
110 if(listFileInDir.size() != 0lu){
111 std::cout <<
"processFileOrDir : get list file in directory '"<<inputFile<<
"' :" << std::endl;
116 for(PVecPath::iterator it(vecKeepDir.begin()); it != vecKeepDir.end(); ++it){
117 *it = inputFile / (*it);
119 std::cout <<
"Number of files = " << vecKeepDir.size() << std::endl;
123 std::cout <<
"processFileOrDir : create file '" << fileName <<
"'" << std::endl;
130 struct stat fileStat;
131 if(stat(inputFile.c_str(), &fileStat) < 0){
133 std::cerr <<
"processFileOrDir : can't get permission of file '"<<inputFile<<
"'" << std::endl;
135 fullMode = fileStat.st_mode;
140 if(hasMode && !isPlatexMode){
142 std::cerr <<
"processFileOrDir : Cannot set mode of file '"<<outputFile<<
"'" << std::endl;
154 if(listInputFile.size() == 0lu){
return true;}
156 for(PVecPath::const_iterator it(listInputFile.begin()); it != listInputFile.end(); ++it){
163 int main(
int argc,
char** argv){
std::vector< PPath > PVecPath
int main(int argc, char **argv)
OptionParser createOptionParser()
Create the OptionParser of this program.
PVecPath pathRemoveIfIgnored(const PVecPath &vecPath, const PVecPath &listIgnoreDir)
Remove Path if they are ignored.
bool createDirectoryWithFiles(const PPath &outputDir, const PPath &directoryName, const PVecPath &listInputFile, const SplitArgument &option)
Process a list of files or directories and create the output directory.
bool processListFile(const SplitArgument &option)
Process a list of files or directories.
bool processFileOrDir(const PPath &outputDir, const PPath &inputFile, const SplitArgument &option)
Process a file or a directory.
bool processFile(const PPath &inputFile, const PString &command, size_t firstToken, size_t lastToken, size_t incrementToken, const PString &delimitor, bool isNoFail)
Process the file.
Describe a mode in the program arguments.
bool isOptionExist(const PString &optionName) const
Say if the given option has been passed to the program.
bool getValue(T &value, const PString &optionName) const
Get the value of the option.
Parse the options passed to a program.
void parseArgument(int argc, char **argv)
Parse the arguments passed to the program.
void addOption(const PString &longOption, const PString &shortOption, OptionType::OptionType optionType, bool isRequired, const PString &docString)
Add an option in the OptionParser.
void setExampleShortOption(const PString &example)
Set the example usage of the program.
void setExampleLongOption(const PString &example)
Set the example usage of the program.
const OptionMode & getDefaultMode() const
Get default mode.
Path of a directory or a file.
bool changeMode(mode_t __mode=S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) const
Change the mode of a file or directory.
bool createDirectory(mode_t mode=0755) const
Create the current directory.
std::vector< PPath > getAllElementInDir() const
Get the list of all elements in a directory.
PPath getFileName() const
Get the name of the file, from last char to /.
PPath getSplitOutputFileName(const PPath &outputFile, bool isPlatexMode)
Get the output file name.
arguments of the phoenix_srcsplittexdir program
PVecPath listIgnoreDir
Directory to be ignored.
bool keepComment
true to keep the comments of the targeted language in the output file
PPath outputDir
name of the output directory
bool isPlatexMode
true to add begin and end environnement in the output file, false otherwise
bool removefirstcomment
remove the first comment of the file
bool keepTex
true to keep the ptex comment, false otherwise
PVecPath listInputFile
list of the input files or directories