diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-11 19:08:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-11 19:19:38 +0300 |
commit | 245fb04a1e112cc8d0918a8660474299d5ce223c (patch) | |
tree | eb5ab6266a4ff9551d2e08b9c14b61e353cd127f /src/resources | |
parent | f978c1bed85961e102951340669ca873328bcef3 (diff) | |
download | manaverse-245fb04a1e112cc8d0918a8660474299d5ce223c.tar.gz manaverse-245fb04a1e112cc8d0918a8660474299d5ce223c.tar.bz2 manaverse-245fb04a1e112cc8d0918a8660474299d5ce223c.tar.xz manaverse-245fb04a1e112cc8d0918a8660474299d5ce223c.zip |
Split virtfs api for add directories and archives.
Also remove useless resourcemanager functions for add/remove virtfs entries.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/dye/dye_unittest.cc | 4 | ||||
-rw-r--r-- | src/resources/dye/dyepalette_unittest.cc | 4 | ||||
-rw-r--r-- | src/resources/map/maplayer_unittest.cc | 14 | ||||
-rw-r--r-- | src/resources/map/speciallayer_unittest.cc | 9 | ||||
-rw-r--r-- | src/resources/resourcemanager/resourcemanager.cpp | 33 | ||||
-rw-r--r-- | src/resources/resourcemanager/resourcemanager.h | 17 | ||||
-rw-r--r-- | src/resources/resourcemanager/resourcemanager_unittest.cc | 4 | ||||
-rw-r--r-- | src/resources/sprite/animatedsprite_unittest.cc | 4 |
8 files changed, 23 insertions, 66 deletions
diff --git a/src/resources/dye/dye_unittest.cc b/src/resources/dye/dye_unittest.cc index f3d4fe3ba..57892c3a9 100644 --- a/src/resources/dye/dye_unittest.cc +++ b/src/resources/dye/dye_unittest.cc @@ -2358,8 +2358,8 @@ TEST_CASE("Dye real dye") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::init(); - resourceManager->addToSearchPath("data/test", Append_false); - resourceManager->addToSearchPath("../data/test", Append_false); + VirtFs::addDirToSearchPath("data/test", Append_false); + VirtFs::addDirToSearchPath("../data/test", Append_false); #ifdef USE_SDL2 imageHelper = new SurfaceImageHelper; diff --git a/src/resources/dye/dyepalette_unittest.cc b/src/resources/dye/dyepalette_unittest.cc index 42770e878..88bffe824 100644 --- a/src/resources/dye/dyepalette_unittest.cc +++ b/src/resources/dye/dyepalette_unittest.cc @@ -59,8 +59,8 @@ TEST_CASE("DyePalette tests") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::init(); - resourceManager->addToSearchPath("data/test", Append_false); - resourceManager->addToSearchPath("../data/test", Append_false); + VirtFs::addDirToSearchPath("data/test", Append_false); + VirtFs::addDirToSearchPath("../data/test", Append_false); mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper(); diff --git a/src/resources/map/maplayer_unittest.cc b/src/resources/map/maplayer_unittest.cc index bd58d998c..75bd20219 100644 --- a/src/resources/map/maplayer_unittest.cc +++ b/src/resources/map/maplayer_unittest.cc @@ -28,6 +28,8 @@ #include "gui/theme.h" +#include "utils/virtfs.h" + #include "render/mockgraphics.h" #include "resources/sdlimagehelper.h" @@ -1645,8 +1647,8 @@ TEST_CASE("MapLayer draw") TEST_CASE("MapLayer drawSpecialLayer (specialLayer)") { ResourceManager::init(); - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); imageHelper = new SDLImageHelper; #ifdef USE_SDL2 @@ -1993,8 +1995,8 @@ TEST_CASE("MapLayer drawSpecialLayer (specialLayer)") TEST_CASE("MapLayer drawSpecialLayer (tempLayer)") { ResourceManager::init(); - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); imageHelper = new SDLImageHelper; #ifdef USE_SDL2 @@ -2347,8 +2349,8 @@ TEST_CASE("MapLayer drawSpecialLayer (tempLayer)") TEST_CASE("MapLayer drawFringe") { ResourceManager::init(); - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); logger = new Logger; imageHelper = new SDLImageHelper; diff --git a/src/resources/map/speciallayer_unittest.cc b/src/resources/map/speciallayer_unittest.cc index b74ade7dc..6c6772332 100644 --- a/src/resources/map/speciallayer_unittest.cc +++ b/src/resources/map/speciallayer_unittest.cc @@ -27,22 +27,23 @@ #include "enums/resources/map/mapitemtype.h" +#include "utils/delete2.h" +#include "utils/virtfs.h" + #include "resources/sdlimagehelper.h" #include "resources/map/speciallayer.h" #include "resources/resourcemanager/resourcemanager.h" -#include "utils/delete2.h" - #include "debug.h" TEST_CASE("SpecialLayer updateCache") { client = new Client; ResourceManager::init(); - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); imageHelper = new SDLImageHelper; #ifdef USE_SDL2 diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp index 322b119a1..86158776d 100644 --- a/src/resources/resourcemanager/resourcemanager.cpp +++ b/src/resources/resourcemanager/resourcemanager.cpp @@ -340,35 +340,6 @@ bool ResourceManager::setWriteDir(const std::string &path) const return static_cast<bool>(VirtFs::setWriteDir(path.c_str())); } -bool ResourceManager::addToSearchPath(const std::string &path, - const Append append) const -{ - logger->log("Adding to PhysicsFS: %s (%s)", path.c_str(), - append == Append_true ? "append" : "prepend"); - if (!VirtFs::addToSearchPath(path.c_str(), - append == Append_true ? 1 : 0)) - { - logger->log("Error: %s: addToSearchPath failed: %s", - path.c_str(), - VirtFs::getLastError()); - return false; - } - return true; -} - -bool ResourceManager::removeFromSearchPath(const std::string &path) const -{ - logger->log("Removing from PhysicsFS: %s", path.c_str()); - if (!VirtFs::removeFromSearchPath(path.c_str())) - { - logger->log("Error: %s: removeFromSearchPath failed: %s", - path.c_str(), - VirtFs::getLastError()); - return false; - } - return true; -} - void ResourceManager::searchAndAddArchives(const std::string &restrict path, const std::string &restrict ext, const Append append) const @@ -385,7 +356,7 @@ void ResourceManager::searchAndAddArchives(const std::string &restrict path, const std::string file = path + (*i); const std::string realPath = std::string( VirtFs::getRealDir(file.c_str())); - addToSearchPath(std::string(realPath).append( + VirtFs::addZipToSearchPath(std::string(realPath).append( dirSep).append(file), append); } } @@ -408,7 +379,7 @@ void ResourceManager::searchAndRemoveArchives(const std::string &restrict path, const std::string file = path + (*i); const std::string realPath = std::string( VirtFs::getRealDir(file.c_str())); - removeFromSearchPath(std::string(realPath).append( + VirtFs::removeZipFromSearchPath(std::string(realPath).append( dirSep).append(file)); } } diff --git a/src/resources/resourcemanager/resourcemanager.h b/src/resources/resourcemanager/resourcemanager.h index 58e74967f..6f6875361 100644 --- a/src/resources/resourcemanager/resourcemanager.h +++ b/src/resources/resourcemanager/resourcemanager.h @@ -68,23 +68,6 @@ class ResourceManager final : public MemoryCounter bool setWriteDir(const std::string &path) const; /** - * Adds a directory or archive to the search path. If append is true - * then the directory is added to the end of the search path, otherwise - * it is added at the front. - * - * @return <code>true</code> on success, <code>false</code> otherwise. - */ - bool addToSearchPath(const std::string &path, - const Append append) const; - - /** - * Remove a directory or archive from the search path. - * - * @return <code>true</code> on success, <code>false</code> otherwise. - */ - bool removeFromSearchPath(const std::string &path) const; - - /** * Searches for zip files and adds them to the search path. */ void searchAndAddArchives(const std::string &restrict path, diff --git a/src/resources/resourcemanager/resourcemanager_unittest.cc b/src/resources/resourcemanager/resourcemanager_unittest.cc index 684f2d839..98ed0ca2f 100644 --- a/src/resources/resourcemanager/resourcemanager_unittest.cc +++ b/src/resources/resourcemanager/resourcemanager_unittest.cc @@ -94,8 +94,8 @@ TEST_CASE("resourcemanager", "resourcemanager") logger = new Logger(); ResourceManager::init(); ResourceManager *safeResman = resourceManager; - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); imageHelper = new SDLImageHelper(); #ifdef USE_SDL2 diff --git a/src/resources/sprite/animatedsprite_unittest.cc b/src/resources/sprite/animatedsprite_unittest.cc index 17746f65c..9505e7d24 100644 --- a/src/resources/sprite/animatedsprite_unittest.cc +++ b/src/resources/sprite/animatedsprite_unittest.cc @@ -60,8 +60,8 @@ TEST_CASE("AnimatedSprite tests", "animatedsprite") SDL_Init(SDL_INIT_VIDEO); logger = new Logger(); ResourceManager::init(); - resourceManager->addToSearchPath("data", Append_false); - resourceManager->addToSearchPath("../data", Append_false); + VirtFs::addDirToSearchPath("data", Append_false); + VirtFs::addDirToSearchPath("../data", Append_false); mainGraphics = new SDLGraphics; imageHelper = new SDLImageHelper(); #ifdef USE_SDL2 |