BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Utility functions to deal with file system. More...
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. More... | |
std::string | extensions (const std::string &path) |
Returns extension(s) of given filename. 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 | 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. More... | |
std::string | stem (const std::string &path) |
Returns filename without (last) extension. More... | |
std::string | stem_ext (const std::string &path) |
Returns filename without extension(s). More... | |
Utility functions to deal with file system.
std::wstring FileSystemUtils::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 109 of file FileSystemUtils.cpp.
Referenced by createDirectories(), createDirectory(), IsFileExists(), IntensityDataIOFactory::readOutputData(), and IntensityDataIOFactory::writeOutputData().
bool FileSystemUtils::createDirectories | ( | const std::string & | dir_name | ) |
Creates directories in current directory for any element of dir_name which doesn't exist.
Definition at line 49 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16().
bool FileSystemUtils::createDirectory | ( | const std::string & | dir_name | ) |
Creates directory in current directory.
Definition at line 40 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16(), and ModelView::Utils::create_directory().
std::string FileSystemUtils::extension | ( | const std::string & | path | ) |
Returns extension of given filename.
"/home/user/filename.int" -> ".int", "/home/user/filename.int.gz" -> ".gz"
Definition at line 25 of file FileSystemUtils.cpp.
Referenced by DataFormatUtils::GetFileMainExtension(), DataFormatUtils::isBZipped(), and DataFormatUtils::isGZipped().
std::string FileSystemUtils::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 30 of file FileSystemUtils.cpp.
References filename(), and RealSpace::Particles::name().
std::string FileSystemUtils::filename | ( | const std::string & | path | ) |
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")
Definition at line 80 of file FileSystemUtils.cpp.
Referenced by TestUtils::CreateEmptyFile(), IHistogram::createFrom(), TestUtils::CreateTestFile(), extensions(), SaveLoadInterface::fileName(), ModelView ::Utils::is_binary(), ModelView ::Utils::is_text(), csv::isAscii(), SessionModel::load(), DataItem::load(), PointwiseAxisItem::load(), IHistogram::load(), ModelView::Project::ProjectImpl::process(), ProjectUtils::removeFile(), SessionModel::save(), IHistogram::save(), DataItem::setFileName(), RealDataItem::setNativeFileName(), JobModelFunctions::setupJobItemInstrument(), stem_ext(), TEST_F(), SpecularBeamItem::updateFileName(), SpecularBeamInclinationItem::updateFileName(), and ParticleView::updatePixmap().
std::vector< std::string > FileSystemUtils::filesInDirectory | ( | const std::string & | dir_name | ) |
Returns filenames of files in directory.
Definition at line 58 of file FileSystemUtils.cpp.
References ProjectUtils::exists().
Referenced by glob().
std::vector< std::string > FileSystemUtils::glob | ( | const std::string & | dir, |
const std::string & | pattern | ||
) |
Returns file names that agree with a regex glob pattern.
Definition at line 85 of file FileSystemUtils.cpp.
References filesInDirectory().
bool FileSystemUtils::IsFileExists | ( | const std::string & | path | ) |
Returns true if file with given name exists on disk.
Definition at line 115 of file FileSystemUtils.cpp.
References convert_utf8_to_utf16(), and ProjectUtils::exists().
Referenced by IntensityDataIOFactory::readOutputData().
std::string FileSystemUtils::jointPath | ( | const std::string & | path1, |
const std::string & | path2 | ||
) |
std::string FileSystemUtils::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 94 of file FileSystemUtils.cpp.
std::string FileSystemUtils::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 99 of file FileSystemUtils.cpp.
References filename(), and RealSpace::Particles::name().