21 #ifdef ENABLE_FILESYSTEM
29 #ifdef ENABLE_FILESYSTEM
32 QFileInfo info(QString::fromStdString(fileName));
37 std::string
Utils::join(
const std::string& part1,
const std::string& part2)
39 #ifdef ENABLE_FILESYSTEM
40 auto path = std::filesystem::path(part1) / std::filesystem::path(part2);
43 return part1 + std::string(
"/") + part2;
49 #ifdef ENABLE_FILESYSTEM
52 QDir dir(QString::fromStdString(path));
53 return dir.mkpath(
".");
59 #ifdef ENABLE_FILESYSTEM
62 QFile file(QString::fromStdString(path));
69 #ifdef ENABLE_FILESYSTEM
72 QDir dir(QString::fromStdString(path));
74 dir.removeRecursively();
80 #ifdef ENABLE_FILESYSTEM
81 return std::filesystem::path(path).stem().string();
83 return QFileInfo(QString::fromStdString(path)).completeBaseName().toStdString();
87 std::vector<std::string>
Utils::FindFiles(
const std::string& dirname,
const std::string& ext)
89 #ifdef ENABLE_FILESYSTEM
90 std::vector<std::string> result;
91 for (
const auto& entry : std::filesystem::directory_iterator(dirname)) {
92 const auto filenameStr = entry.path().filename().string();
93 if (entry.is_regular_file() && entry.path().extension() == ext)
94 result.push_back(entry.path().string());
98 std::vector<std::string> result;
99 QDir dir(QString::fromStdString(dirname));
101 QStringList filters = {QString::fromStdString(
"*" + ext)};
102 for (
auto entry : dir.entryList(filters)) {
103 auto name = dir.filePath(entry);
104 result.push_back(
name.toStdString());
113 #ifdef ENABLE_FILESYSTEM
114 return std::filesystem::path(path).parent_path().string();
116 QFileInfo info(QString::fromStdString(path));
117 return info.dir().path().toStdString();
123 #ifdef ENABLE_FILESYSTEM
126 QFileInfo info(QString::fromStdString(path));
128 QDir dir(QString::fromStdString(path));
129 return dir.isEmpty();
131 return info.size() == 0;
MVVM_MODEL_EXPORT std::string base_name(const std::string &path)
Provide the filename of a file path.
MVVM_MODEL_EXPORT std::vector< std::string > FindFiles(const std::string &dirname, const std::string &ext)
Returns list of files with given extention found in given directory.
MVVM_MODEL_EXPORT bool is_empty(const std::string &path)
Returns true if the file indicated by 'path' refers to empty file or directory.
MVVM_MODEL_EXPORT bool remove(const std::string &path)
Removes file or empty directory.
MVVM_MODEL_EXPORT void remove_all(const std::string &path)
Removes directory with all its content.
MVVM_MODEL_EXPORT std::string parent_path(const std::string &path)
Returns the path to the parent directory.
MVVM_MODEL_EXPORT std::string join(const std::string &part1, const std::string &part2)
Joins two path elements into the path.
MVVM_MODEL_EXPORT bool exists(const std::string &fileName)
Returns true if file exists.
MVVM_MODEL_EXPORT bool create_directory(const std::string &path)
Create directory, parent directory must exist.
materialitems.h Collection of materials to populate MaterialModel.
bool exists(const QString &fileName)
Returns true if file exists.
QString const & name(EShape k)