|
STIR 6.5.0
|
#include "stir/FilePath.h"
Public Member Functions | |
| FilePath (const std::string &__str, bool _run_checks=true) | |
FilePath If the initial path exists in the disk _check should be left true. It will check that the path is writable If you want to initialize to an arbitary string then set _run_checks false. | |
| bool | is_directory () const |
| Returns true if my_string points to a directory. | |
| bool | is_regular_file () const |
Returns true if my_string points to a regular file Returns true if the path is writable. | |
| bool | is_writable () const |
| On Windows the attribute INVALID_FILE_ATTRIBUTES is used. Which is not quite the same. | |
| FilePath | append (const FilePath &p) |
| Create a new folder,by FilePath, and return its path as FilePath. | |
| FilePath | append (const std::string &p) |
| Create a new folder,by string, and return its path. | |
| void | prepend_directory_name (const std::string &p) |
If path is no absolute then prepend the p string. | |
| void | add_extension (const std::string &e) |
Append extension e if none is present. | |
| void | replace_extension (const std::string &e) |
| Replace extension. | |
| std::string | get_path () const |
| Get path from string. | |
| std::string | get_path_only () const |
| Get the path from string. If no path in string returns empty string. | |
| std::string | get_filename () const |
| Get only the filename An inherent functionality from utilities is that on Windows all separators will be checked. | |
| std::string | get_filename_no_extension () const |
| Convinience function which returns the filename withouth the extension. | |
| std::string | get_extension () const |
| Get the extension of the filename. | |
| std::string | get_as_string () const |
| Return the current full string. | |
| std::string | get_string () const |
| bool | operator== (const FilePath &other) |
| bool | operator== (const std::string &other) |
| void | operator= (const FilePath &other) |
| void | operator= (const std::string &other) |
Static Public Member Functions | |
| static bool | is_absolute (const std::string &_filename_with_directory) |
Returns true if the _filename_with_directory is an absolute path. | |
| static bool | exists (const std::string &s) |
Returns true if the path s already exists. | |
| static std::string | get_current_working_directory () |
| Returns the current / working directory. | |
| static void | append_separator (std::string &s) |
| Append the separator. | |
Protected Attributes | |
| std::string | my_string |
| This is the string holding the data. | |
| std::string | separator |
| The separator for the current OS. | |
| bool | run_checks |
| Run checks on the my_string on various occations. You want this when you operate on existing paths. | |
The FilePath class.
The old pathname operations are supported.
| stir::FilePath::FilePath | ( | const std::string & | __str, |
| bool | _run_checks = true ) |
FilePath If the initial path exists in the disk _check should be left true. It will check that the path is writable If you want to initialize to an arbitary string then set _run_checks false.
References stir::error(), my_string, and run_checks.
| bool stir::FilePath::is_directory | ( | ) | const |
Returns true if my_string points to a directory.
References stir::error(), stir::info(), is_directory(), and my_string.
Referenced by append(), is_directory(), and stir::FilenameTests::run_tests().
| bool stir::FilePath::is_regular_file | ( | ) | const |
Returns true if my_string points to a regular file Returns true if the path is writable.
References stir::error(), stir::info(), is_regular_file(), and my_string.
Referenced by append(), and is_regular_file().
| bool stir::FilePath::is_writable | ( | ) | const |
On Windows the attribute INVALID_FILE_ATTRIBUTES is used. Which is not quite the same.
References is_writable(), and my_string.
Referenced by append(), is_writable(), and stir::FilenameTests::run_tests().
|
static |
Returns true if the _filename_with_directory is an absolute path.
References is_absolute().
Referenced by is_absolute(), stir::NiftyPETHelper::lm_to_proj_data(), prepend_directory_name(), and stir::FilenameTests::run_tests().
|
static |
Returns true if the path s already exists.
References exists(), and stir::info().
Referenced by append(), exists(), and stir::FilenameTests::run_tests().
|
static |
Returns the current / working directory.
References get_current_working_directory(), and stir::max_filename_length.
Referenced by stir::PoissonLogLikelihoodWithLinearModelForMeanAndListModeData< TargetT >::get_cache_path(), get_current_working_directory(), stir::NiftyPETHelper::lm_to_proj_data(), stir::FilenameTests::run_tests(), and stir::ScatterEstimation::set_up().
| FilePath stir::FilePath::append | ( | const FilePath & | p | ) |
Create a new folder,by FilePath, and return its path as FilePath.
References append(), and get_path().
Referenced by append(), append(), stir::FilenameTests::run_tests(), and stir::ScatterEstimation::set_up().
| FilePath stir::FilePath::append | ( | const std::string & | p | ) |
Create a new folder,by string, and return its path.
This functions creates appends path p to my_string. It supports multiple new folder levels.It will try to avoid errors as permissions and non existing root path.
References append(), append_separator(), stir::error(), exists(), get_path(), is_directory(), is_regular_file(), is_writable(), my_string, separator, and stir::warning().
|
static |
Append the separator.
References append_separator().
Referenced by append(), and append_separator().
| void stir::FilePath::prepend_directory_name | ( | const std::string & | p | ) |
If path is no absolute then prepend the p string.
References is_absolute(), my_string, prepend_directory_name(), and separator.
Referenced by stir::PoissonLogLikelihoodWithLinearModelForMeanAndListModeData< TargetT >::get_cache_filename(), stir::NiftyPETHelper::lm_to_proj_data(), prepend_directory_name(), stir::ScatterEstimation::process_data(), stir::FilenameTests::run_tests(), and stir::InputStreamFromROOTFile::set_up().
| void stir::FilePath::add_extension | ( | const std::string & | e | ) |
Append extension e if none is present.
References add_extension(), and my_string.
Referenced by add_extension(), and stir::FilenameTests::run_tests().
| void stir::FilePath::replace_extension | ( | const std::string & | e | ) |
Replace extension.
References my_string, and replace_extension().
Referenced by replace_extension(), and stir::FilenameTests::run_tests().
| std::string stir::FilePath::get_path | ( | ) | const |
Get path from string.
References get_path(), my_string, and separator.
Referenced by append(), append(), get_path(), and stir::FilenameTests::run_tests().
| std::string stir::FilePath::get_path_only | ( | ) | const |
Get the path from string. If no path in string returns empty string.
References get_path_only(), my_string, and separator.
Referenced by stir::CListModeDataROOT::CListModeDataROOT(), and get_path_only().
| std::string stir::FilePath::get_filename | ( | ) | const |
Get only the filename An inherent functionality from utilities is that on Windows all separators will be checked.
References get_filename(), my_string, and separator.
Referenced by get_filename(), get_filename_no_extension(), and stir::FilenameTests::run_tests().
| std::string stir::FilePath::get_filename_no_extension | ( | ) | const |
Convinience function which returns the filename withouth the extension.
References get_filename(), and get_filename_no_extension().
Referenced by get_filename_no_extension().
| std::string stir::FilePath::get_extension | ( | ) | const |
Get the extension of the filename.
References get_extension(), and my_string.
Referenced by stir::MultiDynamicDiscretisedDensityOutputFileFormat::actual_write_to_file(), and get_extension().
| std::string stir::FilePath::get_as_string | ( | ) | const |
Return the current full string.
References get_as_string(), and my_string.
Referenced by get_as_string(), stir::PoissonLogLikelihoodWithLinearModelForMeanAndListModeData< TargetT >::get_cache_filename(), stir::NiftyPETHelper::lm_to_proj_data(), and stir::InputStreamFromROOTFile::set_up().
|
inline |
References my_string.
|
protected |
This is the string holding the data.
Referenced by add_extension(), append(), FilePath(), get_as_string(), get_extension(), get_filename(), get_path(), get_path_only(), is_directory(), is_regular_file(), is_writable(), operator=(), prepend_directory_name(), and replace_extension().
|
protected |
The separator for the current OS.
Referenced by append(), get_filename(), get_path(), get_path_only(), and prepend_directory_name().
|
protected |
Run checks on the my_string on various occations. You want this when you operate on existing paths.
Referenced by FilePath().