BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
Utility functions to deal with file system.
Functions | |
std::wstring | convert_utf8_to_utf16 (const std::string &str) |
Converts utf8 string represented by std::string to utf16 string represented by std::wstring. More... | |
bool | createDirectories (const std::string &dir_name) |
Creates directories in current directory for any element of dir_name which doesn't exist. More... | |
bool | createDirectory (const std::string &dir_name) |
Creates directory in current directory. More... | |
std::string | extension (const std::string &path) |
Returns extension of given filename. "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz". More... | |
std::string | extensions (const std::string &path) |
Returns extension(s) of given filename. "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".int.gz". More... | |
std::string | filename (const std::string &path) |
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz") More... | |
std::vector< std::string > | filesInDirectory (const std::string &dir_name) |
Returns filenames of files in directory. More... | |
std::vector< std::string > | glob (const std::string &dir, const std::string &pattern) |
Returns file names that agree with a regex glob pattern. More... | |
bool | hasExtension (const std::string &path, const std::string &ref_extension) |
Returns true if extension of path, converted to lower case, matches given reference extension. More... | |
bool | IsFileExists (const std::string &path) |
Returns true if file with given name exists on disk. More... | |
std::string | jointPath (const std::string &path1, const std::string &path2) |
Returns joint path name. Argument path1 may be empty, argument path2 not. More... | |
std::string | stem (const std::string &path) |
Returns filename without (last) extension. "/home/user/filename.int" -> "filename", "/home/user/filename.int.gz" -> "filename.int". More... | |
std::string | stem_ext (const std::string &path) |
Returns filename without extension(s). "/home/user/filename.int" -> "filename", "/home/user/filename.int.gz" -> "filename". More... | |
std::wstring BaseUtils::Filesystem::convert_utf8_to_utf16 | ( | const std::string & | str | ) |
Converts utf8 string represented by std::string to utf16 string represented by std::wstring.
Definition at line 118 of file FileSystemUtils.cpp.
Referenced by createDirectories(), createDirectory(), IsFileExists(), IOFactory::readDatafield(), and IOFactory::writeDatafield().
bool BaseUtils::Filesystem::createDirectories | ( | const std::string & | dir_name | ) |
Creates directories in current directory for any element of dir_name which doesn't exist.
Definition at line 55 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16().
bool BaseUtils::Filesystem::createDirectory | ( | const std::string & | dir_name | ) |
Creates directory in current directory.
Definition at line 46 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16().
std::string BaseUtils::Filesystem::extension | ( | const std::string & | path | ) |
Returns extension of given filename. "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz".
Definition at line 26 of file FileSystemUtils.cpp.
Referenced by hasExtension().
std::string BaseUtils::Filesystem::extensions | ( | const std::string & | path | ) |
Returns extension(s) of given filename. "/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".int.gz".
Definition at line 36 of file FileSystemUtils.cpp.
References filename().
std::string BaseUtils::Filesystem::filename | ( | const std::string & | path | ) |
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")
Definition at line 88 of file FileSystemUtils.cpp.
Referenced by extensions(), ROOT::Math::MixMaxEngineImpl< ROOT_MM_N >::ReadState(), and stem_ext().
std::vector< std::string > BaseUtils::Filesystem::filesInDirectory | ( | const std::string & | dir_name | ) |
Returns filenames of files in directory.
Definition at line 64 of file FileSystemUtils.cpp.
Referenced by glob().
std::vector< std::string > BaseUtils::Filesystem::glob | ( | const std::string & | dir, |
const std::string & | pattern | ||
) |
Returns file names that agree with a regex glob pattern.
Definition at line 93 of file FileSystemUtils.cpp.
References filesInDirectory().
bool BaseUtils::Filesystem::hasExtension | ( | const std::string & | path, |
const std::string & | ref_extension | ||
) |
Returns true if extension of path, converted to lower case, matches given reference extension.
Definition at line 31 of file FileSystemUtils.cpp.
References extension(), and BaseUtils::String::to_lower().
Referenced by DataUtils::Format::isBZipped(), DataUtils::Format::isGZipped(), DataUtils::Format::isIntFile(), DataUtils::Format::isNicosFile(), and DataUtils::Format::isTiffFile().
bool BaseUtils::Filesystem::IsFileExists | ( | const std::string & | path | ) |
Returns true if file with given name exists on disk.
Definition at line 124 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16().
Referenced by IOFactory::readDatafield().
std::string BaseUtils::Filesystem::jointPath | ( | const std::string & | path1, |
const std::string & | path2 | ||
) |
Returns joint path name. Argument path1 may be empty, argument path2 not.
Definition at line 78 of file FileSystemUtils.cpp.
References ASSERT.
std::string BaseUtils::Filesystem::stem | ( | const std::string & | path | ) |
Returns filename without (last) extension. "/home/user/filename.int" -> "filename", "/home/user/filename.int.gz" -> "filename.int".
Definition at line 103 of file FileSystemUtils.cpp.
std::string BaseUtils::Filesystem::stem_ext | ( | const std::string & | path | ) |
Returns filename without extension(s). "/home/user/filename.int" -> "filename", "/home/user/filename.int.gz" -> "filename".
Definition at line 108 of file FileSystemUtils.cpp.
References filename().