diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/resources/resourcemanager.cpp | 15 | ||||
-rw-r--r-- | src/common/resources/resourcemanager.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/common/resources/resourcemanager.cpp b/src/common/resources/resourcemanager.cpp index 8119a6b..0741c70 100644 --- a/src/common/resources/resourcemanager.cpp +++ b/src/common/resources/resourcemanager.cpp @@ -130,6 +130,21 @@ bool CResourceManager::Exists(const std::string &filename) return PHYSFS_exists(filename.c_str()); } +std::vector<std::string> CResourceManager::ListFiles(const std::string &directory) +{ + std::vector<std::string> result; + + char **files = PHYSFS_enumerateFiles(directory.c_str()); + + for (char **i = files; *i != nullptr; i++) { + result.push_back(*i); + } + + PHYSFS_freeList(files); + + return result; +} + int CResourceManager::SDLClose(SDL_RWops *context) { diff --git a/src/common/resources/resourcemanager.h b/src/common/resources/resourcemanager.h index 4052047..b222048 100644 --- a/src/common/resources/resourcemanager.h +++ b/src/common/resources/resourcemanager.h @@ -16,6 +16,7 @@ #pragma once +#include <vector> #include <string> #include <SDL.h> @@ -33,6 +34,7 @@ public: static SDL_RWops* GetSDLFileHandler(const std::string &filename); static CSNDFile* GetSNDFileHandler(const std::string &filename); static bool Exists(const std::string &filename); + static std::vector<std::string> ListFiles(const std::string &directory); private: static int SDLSeek(SDL_RWops *context, int offset, int whence); |