Merge pull request from cgytrus/main

Fix wrong usage of create_directory/create_directories API
This commit is contained in:
HJfod 2022-12-01 20:36:33 +00:00 committed by GitHub
commit 3656e4e6de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions
loader
include/Geode/utils
src/utils

View file

@ -15,8 +15,8 @@ namespace geode::utils::file {
GEODE_DLL Result<> writeString(ghc::filesystem::path const& path, std::string const& data);
GEODE_DLL Result<> writeBinary(ghc::filesystem::path const& path, byte_array const& data);
GEODE_DLL Result<> createDirectory(ghc::filesystem::path const& path);
GEODE_DLL Result<> createDirectoryAll(ghc::filesystem::path const& path);
GEODE_DLL Result<bool> createDirectory(ghc::filesystem::path const& path);
GEODE_DLL Result<bool> createDirectoryAll(ghc::filesystem::path const& path);
GEODE_DLL Result<std::vector<std::string>> listFiles(std::string const& path);
GEODE_DLL Result<std::vector<std::string>> listFilesRecursively(std::string const& path);

View file

@ -74,26 +74,22 @@ Result<> utils::file::writeBinary(ghc::filesystem::path const& path, byte_array
return Err("Unable to open file");
}
Result<> utils::file::createDirectory(ghc::filesystem::path const& path) {
Result<bool> utils::file::createDirectory(ghc::filesystem::path const& path) {
try {
if (ghc::filesystem::create_directory(path)) {
return Ok();
}
return Ok(ghc::filesystem::create_directory(path));
}
catch (...) {
return Err("Unable to create directory");
}
return Err("Unable to create directory");
}
Result<> utils::file::createDirectoryAll(ghc::filesystem::path const& path) {
Result<bool> utils::file::createDirectoryAll(ghc::filesystem::path const& path) {
try {
if (ghc::filesystem::create_directories(path)) {
return Ok();
}
return Ok(ghc::filesystem::create_directories(path));
}
catch (...) {
return Err("Unable to create directories");
}
return Err("Unable to create directories");
}
Result<std::vector<std::string>> utils::file::listFiles(std::string const& path) {