From 245fb04a1e112cc8d0918a8660474299d5ce223c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 11 Feb 2017 19:08:11 +0300 Subject: Split virtfs api for add directories and archives. Also remove useless resourcemanager functions for add/remove virtfs entries. --- src/resources/resourcemanager/resourcemanager.cpp | 33 ++-------------------- src/resources/resourcemanager/resourcemanager.h | 17 ----------- .../resourcemanager/resourcemanager_unittest.cc | 4 +-- 3 files changed, 4 insertions(+), 50 deletions(-) (limited to 'src/resources/resourcemanager') 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(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 @@ -67,23 +67,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 true on success, false otherwise. - */ - bool addToSearchPath(const std::string &path, - const Append append) const; - - /** - * Remove a directory or archive from the search path. - * - * @return true on success, false otherwise. - */ - bool removeFromSearchPath(const std::string &path) const; - /** * Searches for zip files and adds them to the search 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 -- cgit v1.2.3-70-g09d2