9 #include <boost/filesystem.hpp>
10 #include <boost/algorithm/string.hpp>
25 xprintf(
Warn,
"Creating FileName object before set_io_dirs is called. No file path resolving.\n");
36 file_path=file_path.substr(
output_dir.size()+1);
38 THROW( ExcAbsOutputPath() << EI_Path( file_path ) );
48 void FilePath::set_io_dirs(
const string working_dir,
const string root_input_dir,
const string input,
const string output) {
57 boost::split(dirs, output, boost::is_any_of(
"/"));
59 if ( !(*it).size() )
continue;
74 boost::split(dirs, full_output, boost::is_any_of(
"/"));
76 if ( !(*it).size() )
continue;
99 if (i != std::string::npos) {
100 if (it->second ==
"" )
xprintf(
Warn,
"Substituting placeholder %s with empty value.\n", it->first.c_str());
108 if (path.size() == 0)
xprintf(
UsrErr,
"Path can't be empty!\n");
110 if (path.size() == 1)
return false;
111 return isalpha(path[0]) && (path[1] ==
':');
119 string abs_path = boost::filesystem::current_path().string();
121 boost::replace_all(abs_path,
"\\",
"/");
130 boost::filesystem::create_directories(
139 if (!boost::filesystem::is_directory(dir)) {
140 boost::filesystem::create_directory(dir);
146 boost::filesystem::path working_path = boost::filesystem::path(working_dir);
147 boost::filesystem::path output_path = boost::filesystem::path(output);
151 boost::filesystem::path curr = boost::filesystem::current_path();
152 working_path = boost::filesystem::canonical( curr / working_path );
155 boost::filesystem::path full_path = boost::filesystem::canonical( working_path / output_path );
157 boost::filesystem::path curr = boost::filesystem::current_path();
FileType
Possible types of file.
static void create_dir(string dir)
string abs_file_path
Final absolute path to the file.
static void add_placeholder(string key, string value)
Add new item to place holder.
static string root_dir
Prefix path for input files (directory of the main input file).
static void create_canonical_path(const string working_dir, const string output)
static const string get_absolute_working_dir()
static void set_io_dirs(const string working_dir, const string root_input, const string input, const string output)
static std::map< string, string > placeholder
dictionary of placeholders
static string output_dir
Prefix path for output files.
static bool is_absolute_path(const string path)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
FileType file_type_
File type.