Platform-independent utilities for manipulating file names, files, directories, and other file system miscellany. More...
Functions | |
DLLPUBLIC std::string | file_extension (const std::string &filepath) |
DLLPUBLIC void | searchpath_split (const std::string &searchpath, std::vector< std::string > &dirs, bool validonly=false) |
DLLPUBLIC std::string | searchpath_find (const std::string &filename, const std::vector< std::string > &dirs, bool testcwd=true) |
DLLPUBLIC bool | path_is_absolute (const std::string &path, bool dot_is_absolute=false) |
Platform-independent utilities for manipulating file names, files, directories, and other file system miscellany.
DLLPUBLIC std::string Filesystem::file_extension | ( | const std::string & | filepath | ) |
Return the file extension (just the part after the last '.') of a filename.
DLLPUBLIC bool Filesystem::path_is_absolute | ( | const std::string & | path, | |
bool | dot_is_absolute = false | |||
) |
Return true if the path is an "absolute" (not relative) path. If 'dot_is_absolute' is true, consider "./foo" absolute.
DLLPUBLIC std::string Filesystem::searchpath_find | ( | const std::string & | filename, | |
const std::vector< std::string > & | dirs, | |||
bool | testcwd = true | |||
) |
Find the first instance of a filename existing in a vector of directories, returning the full path as a string. If the file is not found in any of the listed directories, return an empty string. If the filename is absolute, the directory list will not be used. If testcwd is true, "." will be tested before the searchpath; if testcwd is false, "." will only be tested if it's explicitly in dirs.
DLLPUBLIC void Filesystem::searchpath_split | ( | const std::string & | searchpath, | |
std::vector< std::string > & | dirs, | |||
bool | validonly = false | |||
) |
Turn a searchpath (multiple directory paths separated by ':' or ';') into a vector<string> containing each individual directory. If validonly is true, only existing and readable directories will end up in the list. N.B., the directory names will not have trailing slashes.