From 33ccfdfd351de69cb0570e32d25542466b0f0b91 Mon Sep 17 00:00:00 2001 From: ConfiG Date: Thu, 1 Dec 2022 17:11:44 +0300 Subject: [PATCH] fix wrong usage of create_directory(ies) api --- loader/include/Geode/utils/file.hpp | 4 ++-- loader/src/utils/file.cpp | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/loader/include/Geode/utils/file.hpp b/loader/include/Geode/utils/file.hpp index 8089a072..a5452b8e 100644 --- a/loader/include/Geode/utils/file.hpp +++ b/loader/include/Geode/utils/file.hpp @@ -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 createDirectory(ghc::filesystem::path const& path); + GEODE_DLL Result createDirectoryAll(ghc::filesystem::path const& path); GEODE_DLL Result> listFiles(std::string const& path); GEODE_DLL Result> listFilesRecursively(std::string const& path); diff --git a/loader/src/utils/file.cpp b/loader/src/utils/file.cpp index 03c0a237..e44b025c 100644 --- a/loader/src/utils/file.cpp +++ b/loader/src/utils/file.cpp @@ -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 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 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> utils::file::listFiles(std::string const& path) {