This commit is contained in:
fed 2022-01-29 16:50:41 +01:00
parent 28763917ea
commit 5fae85dd35
3 changed files with 8 additions and 0 deletions

View File

@ -93,6 +93,8 @@ namespace ui_scripting::lua
state["io"]["directoryisempty"] = utils::io::directory_is_empty; state["io"]["directoryisempty"] = utils::io::directory_is_empty;
state["io"]["listfiles"] = utils::io::list_files; state["io"]["listfiles"] = utils::io::list_files;
state["io"]["copyfolder"] = utils::io::copy_folder; state["io"]["copyfolder"] = utils::io::copy_folder;
state["io"]["removefile"] = utils::io::remove_file;
state["io"]["removedirectory"] = utils::io::remove_directory;
state["io"]["readfile"] = static_cast<std::string(*)(const std::string&)>(utils::io::read_file); state["io"]["readfile"] = static_cast<std::string(*)(const std::string&)>(utils::io::read_file);
} }

View File

@ -104,6 +104,11 @@ namespace utils::io
return std::filesystem::is_empty(directory); return std::filesystem::is_empty(directory);
} }
bool remove_directory(const std::string& directory)
{
return std::filesystem::remove_all(directory);
}
std::vector<std::string> list_files(const std::string& directory) std::vector<std::string> list_files(const std::string& directory)
{ {
std::vector<std::string> files; std::vector<std::string> files;

View File

@ -16,6 +16,7 @@ namespace utils::io
bool create_directory(const std::string& directory); bool create_directory(const std::string& directory);
bool directory_exists(const std::string& directory); bool directory_exists(const std::string& directory);
bool directory_is_empty(const std::string& directory); bool directory_is_empty(const std::string& directory);
bool remove_directory(const std::string& directory);
std::vector<std::string> list_files(const std::string& directory); std::vector<std::string> list_files(const std::string& directory);
void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target); void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target);
} }