23 namespace fs = std::filesystem;
27 return fs::path(path).extension().string();
36 const auto pos =
name.find_first_of(
'.', 1);
37 return pos != std::string::npos ?
name.substr(pos,
name.size() - pos) : std::string();
54 return fs::create_directories(dir_name);
60 std::vector<std::string> ret;
62 throw std::runtime_error(
"FileSystemUtils::filesInDirectory '" + dir_name
63 +
"' does not exist");
65 for (
const auto& entry : fs::directory_iterator(dir_name))
66 if (entry.is_regular_file())
67 ret.push_back(entry.path().filename().string());
77 return (fs::path(path1) / fs::path(path2)).string();
82 return fs::path(path).filename().string();
87 std::vector<std::string> ret;
89 if (std::regex_match(fname, std::regex(pattern)))
96 return fs::path(path).stem().string();
105 const auto pos =
name.find_first_of(
'.', 1);
106 return pos != std::string::npos ?
name.substr(0, pos) :
name;
111 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
112 return converter.from_bytes(str);
Defines the macro ASSERT.
#define ASSERT(condition)
Defines namespace FileSystemUtils.
std::string extensions(const std::string &path)
Returns extension(s) of given filename.
std::wstring convert_utf8_to_utf16(const std::string &str)
Converts utf8 string represented by std::string to utf16 string represented by std::wstring.
std::string stem_ext(const std::string &path)
Returns filename without extension(s).
bool IsFileExists(const std::string &path)
Returns true if file with given name exists on disk.
std::string extension(const std::string &path)
Returns extension of given filename.
std::string jointPath(const std::string &path1, const std::string &path2)
Returns joint path name.
std::string filename(const std::string &path)
Returns path without directory part ("Foo/Bar/Doz.int.gz" -> "Doz.int.gz")
std::vector< std::string > glob(const std::string &dir, const std::string &pattern)
Returns file names that agree with a regex glob pattern.
std::string stem(const std::string &path)
Returns filename without (last) extension.
std::vector< std::string > filesInDirectory(const std::string &dir_name)
Returns filenames of files in directory.
bool createDirectories(const std::string &dir_name)
Creates directories in current directory for any element of dir_name which doesn't exist.
bool createDirectory(const std::string &dir_name)
Creates directory in current directory.
MVVM_MODEL_EXPORT bool create_directory(const std::string &path)
Create directory, parent directory must exist.
bool exists(const QString &fileName)
Returns true if file exists.
QString const & name(EShape k)