add file::readDirectory as a sane alternative to file::listFiles

This commit is contained in:
HJfod 2023-02-25 11:21:43 +02:00
parent fcfbd0136b
commit 9f60091fbb
2 changed files with 10 additions and 0 deletions

View file

@ -29,9 +29,13 @@ namespace geode::utils::file {
GEODE_DLL Result<> createDirectory(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<> createDirectoryAll(ghc::filesystem::path const& path);
[[deprecated("Use file::readDirectory")]]
GEODE_DLL Result<std::vector<ghc::filesystem::path>> listFiles( GEODE_DLL Result<std::vector<ghc::filesystem::path>> listFiles(
ghc::filesystem::path const& path, bool recursive = false ghc::filesystem::path const& path, bool recursive = false
); );
GEODE_DLL Result<std::vector<ghc::filesystem::path>> readDirectory(
ghc::filesystem::path const& path, bool recursive = false
);
class Unzip; class Unzip;

View file

@ -116,6 +116,12 @@ Result<> utils::file::createDirectoryAll(ghc::filesystem::path const& path) {
Result<std::vector<ghc::filesystem::path>> utils::file::listFiles( Result<std::vector<ghc::filesystem::path>> utils::file::listFiles(
ghc::filesystem::path const& path, bool recursive ghc::filesystem::path const& path, bool recursive
) {
return file::readDirectory(path, recursive);
}
Result<std::vector<ghc::filesystem::path>> utils::file::readDirectory(
ghc::filesystem::path const& path, bool recursive
) { ) {
if (!ghc::filesystem::exists(path)) { if (!ghc::filesystem::exists(path)) {
return Err("Directory does not exist"); return Err("Directory does not exist");