1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/***********************************************/
/**
* @file fileCreateDirectories.cpp
*
* @brief Creates the directory and parent directories as needed.
*
* @author Torsten Mayer-Guerr
* @date 2018-05-12
*/
/***********************************************/
// Latex documentation
#define DOCSTRING docstring
static const char *docstring = R"(
Creates the directory and parent directories as needed.
)";
/***********************************************/
#include "programs/program.h"
#include "inputOutput/system.h"
/***** CLASS ***********************************/
/** @brief Creates the directory and parent directories as needed.
* @ingroup programsGroup */
class FileCreateDirectories
{
public:
void run(Config &config, Parallel::CommunicatorPtr comm);
};
GROOPS_REGISTER_PROGRAM(FileCreateDirectories, SINGLEPROCESS, "Creates the directory and parent directories as needed.", System)
/***********************************************/
void FileCreateDirectories::run(Config &config, Parallel::CommunicatorPtr /*comm*/)
{
try
{
std::vector<FileName> fileNames;
readConfig(config, "directory", fileNames, Config::MUSTSET, "", "");
if(isCreateSchema(config)) return;
for(UInt i=0; i<fileNames.size(); i++)
{
logStatus<<"Create directory <"<<fileNames.at(i)<<">"<<Log::endl;
if(!System::createDirectories(fileNames.at(i)))
throw(Exception("Cannot create directory <"+fileNames.at(i).str()+">"));
}
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
|