From 9f60091fbb136d6f85c4c09f9adb82881bdd787c Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Sat, 25 Feb 2023 11:21:43 +0200 Subject: [PATCH] add file::readDirectory as a sane alternative to file::listFiles --- loader/include/Geode/utils/file.hpp | 4 ++++ loader/src/utils/file.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/loader/include/Geode/utils/file.hpp b/loader/include/Geode/utils/file.hpp index 5e14208c..52a3afdc 100644 --- a/loader/include/Geode/utils/file.hpp +++ b/loader/include/Geode/utils/file.hpp @@ -29,9 +29,13 @@ namespace geode::utils::file { GEODE_DLL Result<> createDirectory(ghc::filesystem::path const& path); GEODE_DLL Result<> createDirectoryAll(ghc::filesystem::path const& path); + [[deprecated("Use file::readDirectory")]] GEODE_DLL Result> listFiles( ghc::filesystem::path const& path, bool recursive = false ); + GEODE_DLL Result> readDirectory( + ghc::filesystem::path const& path, bool recursive = false + ); class Unzip; diff --git a/loader/src/utils/file.cpp b/loader/src/utils/file.cpp index c6f12b65..22f13908 100644 --- a/loader/src/utils/file.cpp +++ b/loader/src/utils/file.cpp @@ -116,6 +116,12 @@ Result<> utils::file::createDirectoryAll(ghc::filesystem::path const& path) { Result> utils::file::listFiles( ghc::filesystem::path const& path, bool recursive +) { + return file::readDirectory(path, recursive); +} + +Result> utils::file::readDirectory( + ghc::filesystem::path const& path, bool recursive ) { if (!ghc::filesystem::exists(path)) { return Err("Directory does not exist");