Automatically create bookmarks folder for user (#3262)

* Automatically creates user bookmarks folder if it does not exist
This commit is contained in:
Andreas Engberg
2024-05-20 17:08:57 +02:00
committed by GitHub
parent 944e345d2e
commit 666135d56f
3 changed files with 23 additions and 1 deletions
+1
View File
@@ -646,6 +646,7 @@ void ScriptEngine::addBaseLibrary() {
codegen::lua::FileExists,
codegen::lua::ReadFile,
codegen::lua::DirectoryExists,
codegen::lua::CreateDirectory,
codegen::lua::WalkDirectory,
codegen::lua::WalkDirectoryFiles,
codegen::lua::WalkDirectoryFolders,
+17 -1
View File
@@ -103,12 +103,28 @@ namespace {
return contents;
}
// Checks whether the provided file exists.
// Checks whether the provided directory exists.
[[codegen::luawrap]] bool directoryExists(std::filesystem::path file) {
const bool e = std::filesystem::is_directory(absPath(std::move(file)));
return e;
}
/**
* Creates a directory at the provided path, returns true if directory was newly created
* and false otherwise. If `recursive` flag is set to true, it will automatically create
* any missing parent folder as well
*/
[[codegen::luawrap]] bool createDirectory(std::filesystem::path path,
bool recursive = false)
{
if (recursive) {
return std::filesystem::create_directories(std::move(path));
}
else {
return std::filesystem::create_directory(std::move(path));
}
}
std::vector<std::filesystem::path> walkCommon(const std::filesystem::path& path,
bool recursive, bool sorted,
std::function<bool(const std::filesystem::path&)> filter)