diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-11 19:59:55 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-11 19:59:55 +0000 |
commit | fc63e88f869919a8b035a5c41db8d05626526bde (patch) | |
tree | 8f1928d082ebbffc549c712a3f406c2141f43e01 /src/resources | |
parent | 7b0f0ec315e66dcbdda58ada8b09a59bc5dcf6c9 (diff) | |
download | mana-fc63e88f869919a8b035a5c41db8d05626526bde.tar.gz mana-fc63e88f869919a8b035a5c41db8d05626526bde.tar.bz2 mana-fc63e88f869919a8b035a5c41db8d05626526bde.tar.xz mana-fc63e88f869919a8b035a5c41db8d05626526bde.zip |
Merged 0.0 changes from revision 3065 to 3177 to trunk.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/resourcemanager.cpp | 27 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 8 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 45067302..2059a5c3 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -112,6 +112,33 @@ ResourceManager::addToSearchPath(const std::string &path, bool append) PHYSFS_addToSearchPath(path.c_str(), append ? 1 : 0); } +void +ResourceManager::searchAndAddArchives(const std::string &path, + const std::string &ext, + bool append) +{ + const char *dirSep = PHYSFS_getDirSeparator(); + char **list = PHYSFS_enumerateFiles(path.c_str()); + + for (char **i = list; *i != NULL; i++) + { + size_t len = strlen(*i); + + if (len > ext.length() && !ext.compare((*i)+(len - ext.length()))) + { + std::string file, realPath, archive; + + file = path + (*i); + realPath = std::string(PHYSFS_getRealDir(file.c_str())); + archive = realPath + dirSep + file; + + addToSearchPath(archive, append); + } + } + + PHYSFS_freeList(list); +} + bool ResourceManager::mkdir(const std::string &path) { diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index d458f96e..e176e337 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -83,6 +83,14 @@ class ResourceManager addToSearchPath(const std::string &path, bool append); /** + * Searches for zip files and adds them to the search path. + */ + void + searchAndAddArchives(const std::string &path, + const std::string &ext, + bool append); + + /** * Creates a directory in the write path */ bool |