From f0b38721e05dbda1d3562abc06fec535d1aa5a07 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Wed, 6 Aug 2014 12:59:27 +0200 Subject: Loading all mods found in "mods" directory --- src/common/resources/resourcemanager.cpp | 15 +++++++++++++++ src/common/resources/resourcemanager.h | 2 ++ 2 files changed, 17 insertions(+) (limited to 'src/common') 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 CResourceManager::ListFiles(const std::string &directory) +{ + std::vector 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 #include #include @@ -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 ListFiles(const std::string &directory); private: static int SDLSeek(SDL_RWops *context, int offset, int whence); -- cgit v1.2.3-1-g7c22