diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-09 03:31:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-09 03:31:42 +0300 |
commit | 612873fa462d74a31bdd3977dac7919376038275 (patch) | |
tree | 86c7ce3cb5a0d334bcba5d463846a88e03a8669e /src/fs | |
parent | 8470d3c82d84a6bd7767de6763153aa9cdfb991b (diff) | |
download | manaplus-612873fa462d74a31bdd3977dac7919376038275.tar.gz manaplus-612873fa462d74a31bdd3977dac7919376038275.tar.bz2 manaplus-612873fa462d74a31bdd3977dac7919376038275.tar.xz manaplus-612873fa462d74a31bdd3977dac7919376038275.zip |
Simplify add/remove dirs and zips methods in virtfs.
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/files.cpp | 8 | ||||
-rw-r--r-- | src/fs/files_unittest.cc | 48 | ||||
-rw-r--r-- | src/fs/physfs/virtfs.cpp | 30 | ||||
-rw-r--r-- | src/fs/physfs/virtfsphys.cpp | 28 | ||||
-rw-r--r-- | src/fs/physfs/virtfsphys.h | 12 | ||||
-rw-r--r-- | src/fs/physfs/virtfsphys_unittest.cc | 124 | ||||
-rw-r--r-- | src/fs/virtfs.h | 18 | ||||
-rw-r--r-- | src/fs/virtfs/virtfs.cpp | 44 | ||||
-rw-r--r-- | src/fs/virtfs/virtfs.h | 10 | ||||
-rw-r--r-- | src/fs/virtfs/virtfs_unittest.cc | 226 | ||||
-rw-r--r-- | src/fs/virtfs_unittest.cc | 204 | ||||
-rw-r--r-- | src/fs/virtfstools.cpp | 4 |
12 files changed, 378 insertions, 378 deletions
diff --git a/src/fs/files.cpp b/src/fs/files.cpp index f6a138475..ab40a7d8f 100644 --- a/src/fs/files.cpp +++ b/src/fs/files.cpp @@ -47,7 +47,7 @@ void Files::extractLocale() const std::string fileName2 = std::string(getenv( "APPDIR")).append("/locale.zip"); - VirtFs::addZipToSearchPath(fileName2, Append_false); + VirtFs::mountZip(fileName2, Append_false); const std::string localDir = std::string(getenv("APPDIR")).append("/"); VirtList *const rootDirs = VirtFs::enumerateFiles("locale"); @@ -67,7 +67,7 @@ void Files::extractLocale() } } VirtFs::freeList(rootDirs); - VirtFs::removeZipFromSearchPath(fileName2); + VirtFs::unmountZip(fileName2); remove(fileName2.c_str()); } #endif // ANDROID @@ -127,9 +127,9 @@ void Files::extractZip(const std::string &restrict zipName, const std::string &restrict inDir, const std::string &restrict outDir) { - VirtFs::addZipToSearchPath(zipName, Append_false); + VirtFs::mountZip(zipName, Append_false); copyPhysFsDir(inDir, outDir); - VirtFs::removeZipFromSearchPath(zipName); + VirtFs::unmountZip(zipName); remove(zipName.c_str()); } diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc index d2bac3256..473e0cbdc 100644 --- a/src/fs/files_unittest.cc +++ b/src/fs/files_unittest.cc @@ -36,8 +36,8 @@ TEST_CASE("Files renameFile") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); const int sz = 1234567; char *buf = new char[sz]; @@ -65,8 +65,8 @@ TEST_CASE("Files renameFile") delete [] buf; delete [] buf2; ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } @@ -75,14 +75,14 @@ TEST_CASE("Files existsLocal") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); REQUIRE(Files::existsLocal(VirtFs::getPath("help/about.txt")) == true); REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help/about1.txt"))); REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help1/about.txt"))); ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } @@ -91,13 +91,13 @@ TEST_CASE("Files loadTextFileString") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); REQUIRE(VirtFs::loadTextFileString("test/simplefile.txt") == "this is test \nfile."); ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } @@ -106,8 +106,8 @@ TEST_CASE("Files loadTextFile") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); StringVect lines; VirtFs::loadTextFile("test/simplefile.txt", lines); @@ -115,8 +115,8 @@ TEST_CASE("Files loadTextFile") REQUIRE(lines[0] == "this is test "); REQUIRE(lines[1] == "file."); ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } @@ -125,8 +125,8 @@ TEST_CASE("Files saveTextFile") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); const std::string dir = VirtFs::getPath("test"); REQUIRE(dir.size() > 0); @@ -141,8 +141,8 @@ TEST_CASE("Files saveTextFile") #endif // WIN32 ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } @@ -151,8 +151,8 @@ TEST_CASE("Files getFilesInDir") { logger = new Logger(); ResourceManager::init(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); StringVect list; VirtFs::getFilesInDir("test", @@ -172,8 +172,8 @@ TEST_CASE("Files getFilesInDir") REQUIRE(list[3] == "perserver/default/features.xml"); REQUIRE(list[4] == "perserver/default/weapons.xml"); ResourceManager::deleteInstance(); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); // VirtFs::deinit(); } diff --git a/src/fs/physfs/virtfs.cpp b/src/fs/physfs/virtfs.cpp index e678e0224..c9fd34ba4 100644 --- a/src/fs/physfs/virtfs.cpp +++ b/src/fs/physfs/virtfs.cpp @@ -104,37 +104,37 @@ namespace VirtFs return VirtFsPhys::setWriteDir(newDir); } - bool addDirToSearchPath(std::string newDir, - const Append append) + bool mountDir(std::string newDir, + const Append append) { - return VirtFsPhys::addDirToSearchPath(newDir, append); + return VirtFsPhys::mountDir(newDir, append); } - bool addDirToSearchPathSilent(std::string newDir, - const Append append) + bool mountDirSilent(std::string newDir, + const Append append) { - return VirtFsPhys::addDirToSearchPath(newDir, append); + return VirtFsPhys::mountDir(newDir, append); } - bool removeDirFromSearchPath(std::string oldDir) + bool unmountDir(std::string oldDir) { - return VirtFsPhys::removeDirFromSearchPath(oldDir); + return VirtFsPhys::unmountDir(oldDir); } - bool removeDirFromSearchPathSilent(std::string oldDir) + bool unmountDirSilent(std::string oldDir) { - return VirtFsPhys::removeDirFromSearchPath(oldDir); + return VirtFsPhys::unmountDir(oldDir); } - bool addZipToSearchPath(std::string newDir, - const Append append) + bool mountZip(std::string newDir, + const Append append) { - return VirtFsPhys::addZipToSearchPath(newDir, append); + return VirtFsPhys::mountZip(newDir, append); } - bool removeZipFromSearchPath(std::string oldDir) + bool unmountZip(std::string oldDir) { - return VirtFsPhys::removeZipFromSearchPath(oldDir); + return VirtFsPhys::unmountZip(oldDir); } std::string getRealDir(std::string filename) diff --git a/src/fs/physfs/virtfsphys.cpp b/src/fs/physfs/virtfsphys.cpp index 439ed2890..f6d0abf47 100644 --- a/src/fs/physfs/virtfsphys.cpp +++ b/src/fs/physfs/virtfsphys.cpp @@ -180,73 +180,73 @@ namespace VirtFsPhys return PHYSFS_setWriteDir(newDir.c_str()); } - bool addDirToSearchPath(const std::string &restrict newDir, - const Append append) + bool mountDir(const std::string &restrict newDir, + const Append append) { logger->log("Add virtual directory: " + newDir); if (newDir.find(".zip") != std::string::npos) { - reportAlways("Called addDirToSearchPath with zip archive"); + reportAlways("Called mountDir with zip archive"); return false; } const int ret = PHYSFS_addToSearchPath(newDir.c_str(), append == Append_true ? 1 : 0); if (ret == 0) { - logger->log("addDirToSearchPath error: %s", + logger->log("mountDir error: %s", VirtFsPhys::getLastError()); } return ret; } - bool removeDirFromSearchPath(const std::string &restrict oldDir) + bool unmountDir(const std::string &restrict oldDir) { logger->log("Remove virtual directory: " + oldDir); if (oldDir.find(".zip") != std::string::npos) { - reportAlways("Called removeDirFromSearchPath with zip archive"); + reportAlways("Called unmountDir with zip archive"); return false; } const int ret = PHYSFS_removeFromSearchPath(oldDir.c_str()); if (ret == 0) { - logger->log("removeDirFromSearchPath error: %s", + logger->log("unmountDir error: %s", VirtFsPhys::getLastError()); } return ret; } - bool addZipToSearchPath(const std::string &restrict newDir, - const Append append) + bool mountZip(const std::string &restrict newDir, + const Append append) { logger->log("Add virtual zip: " + newDir); if (newDir.find(".zip") == std::string::npos) { - reportAlways("Called addZipToSearchPath without zip archive"); + reportAlways("Called mountZip without zip archive"); return false; } const int ret = PHYSFS_addToSearchPath(newDir.c_str(), append == Append_true ? 1 : 0); if (ret == 0) { - logger->log("addZipToSearchPath error: %s", + logger->log("mountZip error: %s", VirtFsPhys::getLastError()); } return ret; } - bool removeZipFromSearchPath(const std::string &restrict oldDir) + bool unmountZip(const std::string &restrict oldDir) { logger->log("Remove virtual zip: " + oldDir); if (oldDir.find(".zip") == std::string::npos) { - reportAlways("Called removeZipFromSearchPath without zip archive"); + reportAlways("Called unmountZip without zip archive"); return false; } const int ret = PHYSFS_removeFromSearchPath(oldDir.c_str()); if (ret == 0) { - logger->log("removeZipFromSearchPath error: %s", + logger->log("unmountZip error: %s", VirtFsPhys::getLastError()); } return ret; diff --git a/src/fs/physfs/virtfsphys.h b/src/fs/physfs/virtfsphys.h index 42394b56b..97b70aae6 100644 --- a/src/fs/physfs/virtfsphys.h +++ b/src/fs/physfs/virtfsphys.h @@ -50,12 +50,12 @@ namespace VirtFsPhys VirtFile *openWrite(const std::string &restrict filename); VirtFile *openAppend(const std::string &restrict filename); bool setWriteDir(const std::string &restrict newDir); - bool addDirToSearchPath(const std::string &restrict newDir, - const Append append); - bool removeDirFromSearchPath(const std::string &restrict oldDir); - bool addZipToSearchPath(const std::string &restrict newDir, - const Append append); - bool removeZipFromSearchPath(const std::string &restrict oldDir); + bool mountDir(const std::string &restrict newDir, + const Append append); + bool unmountDir(const std::string &restrict oldDir); + bool mountZip(const std::string &restrict newDir, + const Append append); + bool unmountZip(const std::string &restrict oldDir); std::string getRealDir(const std::string &restrict filename); bool mkdir(const std::string &restrict dirName); bool remove(const std::string &restrict filename); diff --git a/src/fs/physfs/virtfsphys_unittest.cc b/src/fs/physfs/virtfsphys_unittest.cc index 8137cfb45..429579b05 100644 --- a/src/fs/physfs/virtfsphys_unittest.cc +++ b/src/fs/physfs/virtfsphys_unittest.cc @@ -61,32 +61,32 @@ TEST_CASE("VirtFsPhys exists") { VirtFsPhys::initFuncs(); logger = new Logger(); - VirtFsPhys::addDirToSearchPath("data", Append_false); - VirtFsPhys::addDirToSearchPath("../data", Append_false); + VirtFsPhys::mountDir("data", Append_false); + VirtFsPhys::mountDir("../data", Append_false); REQUIRE(VirtFsPhys::exists("test/units.xml") == true); REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); REQUIRE(VirtFsPhys::exists("units.xml") == false); - VirtFsPhys::addDirToSearchPath("data/test", Append_false); - VirtFsPhys::addDirToSearchPath("../data/test", Append_false); + VirtFsPhys::mountDir("data/test", Append_false); + VirtFsPhys::mountDir("../data/test", Append_false); REQUIRE(VirtFsPhys::exists("test/units.xml") == true); REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); REQUIRE(VirtFsPhys::exists("units.xml") == true); - VirtFsPhys::removeDirFromSearchPath("data/test"); - VirtFsPhys::removeDirFromSearchPath("../data/test"); + VirtFsPhys::unmountDir("data/test"); + VirtFsPhys::unmountDir("../data/test"); REQUIRE(VirtFsPhys::exists("test/units.xml") == true); REQUIRE(VirtFsPhys::exists("test/units123.xml") == false); REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); REQUIRE(VirtFsPhys::exists("units.xml") == false); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); delete2(logger); } @@ -94,8 +94,8 @@ TEST_CASE("VirtFsPhys exists2") { VirtFsPhys::initFuncs(); logger = new Logger(); - VirtFsPhys::addZipToSearchPath("data/test/test2.zip", Append_false); - VirtFsPhys::addZipToSearchPath("../data/test/test2.zip", Append_false); + VirtFsPhys::mountZip("data/test/test2.zip", Append_false); + VirtFsPhys::mountZip("../data/test/test2.zip", Append_false); REQUIRE(VirtFsPhys::exists("test/units.xml") == false); REQUIRE(VirtFsPhys::exists("test.txt") == true); @@ -103,8 +103,8 @@ TEST_CASE("VirtFsPhys exists2") REQUIRE(VirtFsPhys::exists("tesQ/units.xml") == false); REQUIRE(VirtFsPhys::exists("units.xml") == true); - VirtFsPhys::removeZipFromSearchPath("data/test/test2.zip"); - VirtFsPhys::removeZipFromSearchPath("../data/test/test2.zip"); + VirtFsPhys::unmountZip("data/test/test2.zip"); + VirtFsPhys::unmountZip("../data/test/test2.zip"); delete2(logger); } @@ -139,8 +139,8 @@ TEST_CASE("VirtFsPhys enumerateFiles1") VirtFsPhys::initFuncs(); logger = new Logger; - VirtFsPhys::addDirToSearchPath("data", Append_false); - VirtFsPhys::addDirToSearchPath("../data", Append_false); + VirtFsPhys::mountDir("data", Append_false); + VirtFsPhys::mountDir("../data", Append_false); VirtList *list = nullptr; @@ -166,8 +166,8 @@ TEST_CASE("VirtFsPhys enumerateFiles1") REQUIRE(list->names.size() == cnt1); VirtFsPhys::freeList(list); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); delete2(logger); } @@ -176,9 +176,9 @@ TEST_CASE("VirtFsPhys enumerateFiles2") VirtFsPhys::initFuncs(); logger = new Logger; - VirtFsPhys::addDirToSearchPath("data/test/dir1", + VirtFsPhys::mountDir("data/test/dir1", Append_false); - VirtFsPhys::addDirToSearchPath("../data/test/dir1", + VirtFsPhys::mountDir("../data/test/dir1", Append_false); VirtList *list = nullptr; @@ -188,8 +188,8 @@ TEST_CASE("VirtFsPhys enumerateFiles2") REQUIRE(list->names.size() == 5); VirtFsPhys::freeList(list); - VirtFsPhys::removeDirFromSearchPath("data/test/dir1"); - VirtFsPhys::removeDirFromSearchPath("../data/test/dir1"); + VirtFsPhys::unmountDir("data/test/dir1"); + VirtFsPhys::unmountDir("../data/test/dir1"); delete2(logger); } @@ -209,9 +209,9 @@ TEST_CASE("VirtFsPhys enumerateFiles3") VirtFsPhys::initFuncs(); logger = new Logger; - VirtFsPhys::addZipToSearchPath("data/test/test.zip", + VirtFsPhys::mountZip("data/test/test.zip", Append_false); - VirtFsPhys::addZipToSearchPath("../data/test/test.zip", + VirtFsPhys::mountZip("../data/test/test.zip", Append_false); VirtList *list = nullptr; @@ -221,8 +221,8 @@ TEST_CASE("VirtFsPhys enumerateFiles3") REQUIRE(inList(list, "test.txt") == false); VirtFsPhys::freeList(list); - VirtFsPhys::removeZipFromSearchPath("data/test/test.zip"); - VirtFsPhys::removeZipFromSearchPath("../data/test/test.zip"); + VirtFsPhys::unmountZip("data/test/test.zip"); + VirtFsPhys::unmountZip("../data/test/test.zip"); delete2(logger); } @@ -231,9 +231,9 @@ TEST_CASE("VirtFsPhys enumerateFiles4") VirtFsPhys::initFuncs(); logger = new Logger; - VirtFsPhys::addZipToSearchPath("data/test/test2.zip", + VirtFsPhys::mountZip("data/test/test2.zip", Append_false); - VirtFsPhys::addZipToSearchPath("../data/test/test2.zip", + VirtFsPhys::mountZip("../data/test/test2.zip", Append_false); VirtList *list = nullptr; @@ -243,8 +243,8 @@ TEST_CASE("VirtFsPhys enumerateFiles4") REQUIRE(inList(list, "test.txt") == true); VirtFsPhys::freeList(list); - VirtFsPhys::removeZipFromSearchPath("data/test/test2.zip"); - VirtFsPhys::removeZipFromSearchPath("../data/test/test2.zip"); + VirtFsPhys::unmountZip("data/test/test2.zip"); + VirtFsPhys::unmountZip("../data/test/test2.zip"); delete2(logger); } @@ -252,8 +252,8 @@ TEST_CASE("VirtFsPhys isDirectory") { VirtFsPhys::initFuncs(); logger = new Logger(); - VirtFsPhys::addDirToSearchPath("data", Append_false); - VirtFsPhys::addDirToSearchPath("../data", Append_false); + VirtFsPhys::mountDir("data", Append_false); + VirtFsPhys::mountDir("../data", Append_false); REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); REQUIRE(VirtFsPhys::isDirectory("test/units.xml/") == false); @@ -276,8 +276,8 @@ TEST_CASE("VirtFsPhys isDirectory") REQUIRE(VirtFsPhys::isDirectory("testQ/") == false); REQUIRE(VirtFsPhys::isDirectory("testQ//") == false); - VirtFsPhys::addDirToSearchPath("data/test", Append_false); - VirtFsPhys::addDirToSearchPath("../data/test", Append_false); + VirtFsPhys::mountDir("data/test", Append_false); + VirtFsPhys::mountDir("../data/test", Append_false); REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); REQUIRE(VirtFsPhys::isDirectory("test/units.xml/") == false); @@ -289,8 +289,8 @@ TEST_CASE("VirtFsPhys isDirectory") REQUIRE(VirtFsPhys::isDirectory("testQ") == false); REQUIRE(VirtFsPhys::isDirectory("test/dir1") == true); - VirtFsPhys::removeDirFromSearchPath("data/test"); - VirtFsPhys::removeDirFromSearchPath("../data/test"); + VirtFsPhys::unmountDir("data/test"); + VirtFsPhys::unmountDir("../data/test"); REQUIRE(VirtFsPhys::isDirectory("test/units.xml") == false); REQUIRE(VirtFsPhys::isDirectory("test/units123.xml") == false); @@ -302,8 +302,8 @@ TEST_CASE("VirtFsPhys isDirectory") REQUIRE(VirtFsPhys::isDirectory("testQ") == false); REQUIRE(VirtFsPhys::isDirectory("test/dir1") == true); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); delete2(logger); } @@ -311,8 +311,8 @@ TEST_CASE("VirtFsPhys openRead") { VirtFsPhys::initFuncs(); logger = new Logger(); - VirtFsPhys::addDirToSearchPath("data", Append_false); - VirtFsPhys::addDirToSearchPath("../data", Append_false); + VirtFsPhys::mountDir("data", Append_false); + VirtFsPhys::mountDir("../data", Append_false); VirtFile *file = nullptr; @@ -330,8 +330,8 @@ TEST_CASE("VirtFsPhys openRead") file = VirtFsPhys::openRead("testQ"); REQUIRE(file == nullptr); - VirtFsPhys::addDirToSearchPath("data/test", Append_false); - VirtFsPhys::addDirToSearchPath("../data/test", Append_false); + VirtFsPhys::mountDir("data/test", Append_false); + VirtFsPhys::mountDir("../data/test", Append_false); file = VirtFsPhys::openRead("test/units.xml"); REQUIRE(file != nullptr); @@ -348,8 +348,8 @@ TEST_CASE("VirtFsPhys openRead") file = VirtFsPhys::openRead("testQ"); REQUIRE(file == nullptr); - VirtFsPhys::removeDirFromSearchPath("data/test"); - VirtFsPhys::removeDirFromSearchPath("../data/test"); + VirtFsPhys::unmountDir("data/test"); + VirtFsPhys::unmountDir("../data/test"); file = VirtFsPhys::openRead("test/units.xml"); REQUIRE(file != nullptr); @@ -365,17 +365,17 @@ TEST_CASE("VirtFsPhys openRead") file = VirtFsPhys::openRead("testQ"); REQUIRE(file == nullptr); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); delete2(logger); } -TEST_CASE("VirtFsPhys addZipToSearchPath") +TEST_CASE("VirtFsPhys mountZip") { // +++ need implement } -TEST_CASE("VirtFsPhys removeZipFromSearchPath") +TEST_CASE("VirtFsPhys unmountZip") { // +++ need implement } @@ -386,8 +386,8 @@ TEST_CASE("VirtFsPhys getRealDir") logger = new Logger(); REQUIRE(VirtFsPhys::getRealDir(".") == ""); REQUIRE(VirtFsPhys::getRealDir("..") == ""); - const bool dir1 = VirtFsPhys::addDirToSearchPath("data", Append_false); - REQUIRE((dir1 || VirtFsPhys::addDirToSearchPath( + const bool dir1 = VirtFsPhys::mountDir("data", Append_false); + REQUIRE((dir1 || VirtFsPhys::mountDir( "../data", Append_false)) == true); if (dir1 == true) { @@ -403,8 +403,8 @@ TEST_CASE("VirtFsPhys getRealDir") } REQUIRE(VirtFsPhys::getRealDir("zzz") == ""); - VirtFsPhys::addDirToSearchPath("data/test", Append_false); - VirtFsPhys::addDirToSearchPath("../data/test", Append_false); + VirtFsPhys::mountDir("data/test", Append_false); + VirtFsPhys::mountDir("../data/test", Append_false); if (dir1 == true) { REQUIRE(VirtFsPhys::getRealDir("test") == "data"); @@ -425,21 +425,21 @@ TEST_CASE("VirtFsPhys getRealDir") if (dir1 == true) { - VirtFsPhys::addZipToSearchPath("data/test/test.zip", Append_false); + VirtFsPhys::mountZip("data/test/test.zip", Append_false); REQUIRE(VirtFsPhys::getRealDir("dir/brimmedhat.png") == "data/test/test.zip"); REQUIRE(VirtFsPhys::getRealDir("hide.png") == "data/test"); } else { - VirtFsPhys::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFsPhys::mountZip("../data/test/test.zip", Append_false); REQUIRE(VirtFsPhys::getRealDir("dir/brimmedhat.png") == "../data/test/test.zip"); REQUIRE(VirtFsPhys::getRealDir("hide.png") == "../data/test"); } - VirtFsPhys::removeDirFromSearchPath("data/test"); - VirtFsPhys::removeDirFromSearchPath("../data/test"); + VirtFsPhys::unmountDir("data/test"); + VirtFsPhys::unmountDir("../data/test"); if (dir1 == true) { @@ -460,10 +460,10 @@ TEST_CASE("VirtFsPhys getRealDir") REQUIRE(VirtFsPhys::exists("dir/hide.png")); REQUIRE(VirtFsPhys::getRealDir("zzz") == ""); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); - VirtFsPhys::removeZipFromSearchPath("data/test/test.zip"); - VirtFsPhys::removeZipFromSearchPath("../data/test/test.zip"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); + VirtFsPhys::unmountZip("data/test/test.zip"); + VirtFsPhys::unmountZip("../data/test/test.zip"); delete2(logger); } @@ -471,8 +471,8 @@ TEST_CASE("VirtFsPhys read") { VirtFsPhys::initFuncs(); logger = new Logger(); - VirtFsPhys::addDirToSearchPath("data", Append_false); - VirtFsPhys::addDirToSearchPath("../data", Append_false); + VirtFsPhys::mountDir("data", Append_false); + VirtFsPhys::mountDir("../data", Append_false); VirtFile *file = VirtFsPhys::openRead("test/test.txt"); REQUIRE(file != nullptr); @@ -499,8 +499,8 @@ TEST_CASE("VirtFsPhys read") VirtFsPhys::close(file); free(buffer); - VirtFsPhys::removeDirFromSearchPath("data"); - VirtFsPhys::removeDirFromSearchPath("../data"); + VirtFsPhys::unmountDir("data"); + VirtFsPhys::unmountDir("../data"); delete2(logger); } #endif // USE_PHYSFS diff --git a/src/fs/virtfs.h b/src/fs/virtfs.h index f27afac67..0b0a4b5d3 100644 --- a/src/fs/virtfs.h +++ b/src/fs/virtfs.h @@ -46,15 +46,15 @@ namespace VirtFs VirtFile *openWrite(std::string filename); VirtFile *openAppend(std::string filename); bool setWriteDir(const std::string &restrict newDir); - bool addDirToSearchPath(std::string newDir, - const Append append); - bool addDirToSearchPathSilent(std::string newDir, - const Append append); - bool removeDirFromSearchPath(std::string oldDir); - bool removeDirFromSearchPathSilent(std::string oldDir); - bool addZipToSearchPath(std::string newDir, - const Append append); - bool removeZipFromSearchPath(std::string oldDir); + bool mountDir(std::string newDir, + const Append append); + bool mountDirSilent(std::string newDir, + const Append append); + bool unmountDir(std::string oldDir); + bool unmountDirSilent(std::string oldDir); + bool mountZip(std::string newDir, + const Append append); + bool unmountZip(std::string oldDir); std::string getRealDir(std::string filename); bool mkdir(const std::string &restrict dirName); bool remove(const std::string &restrict filename); diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp index ad9c28d53..9cc36fda8 100644 --- a/src/fs/virtfs/virtfs.cpp +++ b/src/fs/virtfs/virtfs.cpp @@ -271,8 +271,8 @@ namespace VirtFs mEntries.insert(mEntries.begin(), entry); } - bool addDirToSearchPathInternal(const std::string &restrict newDir, - const Append append) + bool mountDirInternal(const std::string &restrict newDir, + const Append append) { if (newDir.find(".zip") != std::string::npos) { @@ -295,8 +295,8 @@ namespace VirtFs return true; } - bool addDirToSearchPath(std::string newDir, - const Append append) + bool mountDir(std::string newDir, + const Append append) { prepareFsPath(newDir); if (Files::existsLocal(newDir) == false) @@ -305,11 +305,11 @@ namespace VirtFs newDir.c_str()); return false; } - return addDirToSearchPathInternal(newDir, append); + return mountDirInternal(newDir, append); } - bool addDirToSearchPathSilent(std::string newDir, - const Append append) + bool mountDirSilent(std::string newDir, + const Append append) { prepareFsPath(newDir); if (Files::existsLocal(newDir) == false) @@ -318,12 +318,12 @@ namespace VirtFs newDir.c_str()); return false; } - return addDirToSearchPathInternal(newDir, append); + return mountDirInternal(newDir, append); } #ifdef UNITTESTS - bool addDirToSearchPathSilent2(std::string newDir, - const Append append) + bool mountDirSilent2(std::string newDir, + const Append append) { prepareFsPath(newDir); if (Files::existsLocal(newDir) == false) @@ -331,11 +331,11 @@ namespace VirtFs logger->log("VirtFs::addToSearchPath directory not exists: %s", newDir.c_str()); } - return addDirToSearchPathInternal(newDir, append); + return mountDirInternal(newDir, append); } #endif // UNITTESTS - bool removeDirFromSearchPathInternal(std::string oldDir) + bool unmountDirInternal(std::string oldDir) { if (findLast(oldDir, std::string(dirSeparator)) == false) oldDir += dirSeparator; @@ -356,7 +356,7 @@ namespace VirtFs return false; } - bool removeDirFromSearchPath(std::string oldDir) + bool unmountDir(std::string oldDir) { prepareFsPath(oldDir); if (oldDir.find(".zip") != std::string::npos) @@ -364,16 +364,16 @@ namespace VirtFs reportAlways("Called removeFromSearchPath with zip archive"); return false; } - if (removeDirFromSearchPathInternal(oldDir) == false) + if (unmountDirInternal(oldDir) == false) { - reportAlways("VirtFs::removeDirFromSearchPath not exists: %s", + reportAlways("VirtFs::unmountDir not exists: %s", oldDir.c_str()); return false; } return true; } - bool removeDirFromSearchPathSilent(std::string oldDir) + bool unmountDirSilent(std::string oldDir) { prepareFsPath(oldDir); if (oldDir.find(".zip") != std::string::npos) @@ -381,17 +381,17 @@ namespace VirtFs reportAlways("Called removeFromSearchPath with zip archive"); return false; } - if (removeDirFromSearchPathInternal(oldDir) == false) + if (unmountDirInternal(oldDir) == false) { - logger->log("VirtFs::removeDirFromSearchPath not exists: %s", + logger->log("VirtFs::unmountDir not exists: %s", oldDir.c_str()); return false; } return true; } - bool addZipToSearchPath(std::string newDir, - const Append append) + bool mountZip(std::string newDir, + const Append append) { prepareFsPath(newDir); if (Files::existsLocal(newDir) == false) @@ -425,7 +425,7 @@ namespace VirtFs return true; } - bool removeZipFromSearchPath(std::string oldDir) + bool unmountZip(std::string oldDir) { prepareFsPath(oldDir); if (findLast(oldDir, ".zip") == false) @@ -448,7 +448,7 @@ namespace VirtFs } } - reportAlways("VirtFs::removeZipFromSearchPath not exists: %s", + reportAlways("VirtFs::unmountZip not exists: %s", oldDir.c_str()); return false; } diff --git a/src/fs/virtfs/virtfs.h b/src/fs/virtfs/virtfs.h index 056cb3673..408a54832 100644 --- a/src/fs/virtfs/virtfs.h +++ b/src/fs/virtfs/virtfs.h @@ -34,9 +34,9 @@ struct VirtFsEntry; namespace VirtFs { - bool addDirToSearchPathInternal(const std::string &restrict newDir, - const Append append); - bool removeDirFromSearchPathInternal(std::string oldDir); + bool mountDirInternal(const std::string &restrict newDir, + const Append append); + bool unmountDirInternal(std::string oldDir); std::vector<VirtFsEntry*> &getEntries(); VirtFsEntry *searchEntryByRootInternal(const std::string &restrict root); @@ -45,8 +45,8 @@ namespace VirtFs void addEntry(VirtFsEntry *const entry, const Append append); #ifdef UNITTESTS - bool addDirToSearchPathSilent2(std::string newDir, - const Append append); + bool mountDirSilent2(std::string newDir, + const Append append); #endif // UNITTESTS } // namespace VirtFs diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc index 8047c879c..bf040d707 100644 --- a/src/fs/virtfs/virtfs_unittest.cc +++ b/src/fs/virtfs/virtfs_unittest.cc @@ -51,14 +51,14 @@ TEST_CASE("VirtFs1 getBaseDir") VirtFs::deinit(); } -TEST_CASE("VirtFs1 addDirToSearchPath") +TEST_CASE("VirtFs1 mountDir") { VirtFs::init("."); logger = new Logger(); const std::string sep = dirSeparator; SECTION("simple 1") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr); REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr); @@ -71,7 +71,7 @@ TEST_CASE("VirtFs1 addDirToSearchPath") SECTION("simple 2") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1/", + REQUIRE(VirtFs::mountDirSilent2("dir1/", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr); REQUIRE(VirtFs::searchEntryByRootInternal("test" + sep) == nullptr); @@ -84,9 +84,9 @@ TEST_CASE("VirtFs1 addDirToSearchPath") SECTION("simple 3") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_false)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2", + REQUIRE(VirtFs::mountDirSilent2("dir2", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr); REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr); @@ -104,9 +104,9 @@ TEST_CASE("VirtFs1 addDirToSearchPath") SECTION("simple 4") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1\\", + REQUIRE(VirtFs::mountDirSilent2("dir1\\", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2", + REQUIRE(VirtFs::mountDirSilent2("dir2", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr); REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr); @@ -124,11 +124,11 @@ TEST_CASE("VirtFs1 addDirToSearchPath") SECTION("simple 5") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2", + REQUIRE(VirtFs::mountDirSilent2("dir2", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3/test", + REQUIRE(VirtFs::mountDirSilent2("dir3/test", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal("dir1" + sep) != nullptr); REQUIRE(VirtFs::searchEntryByRootInternal("dir2" + sep) != nullptr); @@ -152,11 +152,11 @@ TEST_CASE("VirtFs1 addDirToSearchPath") SECTION("simple 6") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2", + REQUIRE(VirtFs::mountDirSilent2("dir2", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3\\test", + REQUIRE(VirtFs::mountDirSilent2("dir3\\test", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal( "dir1" + sep + "") != nullptr); @@ -185,7 +185,7 @@ TEST_CASE("VirtFs1 addDirToSearchPath") delete2(logger); } -TEST_CASE("VirtFs1 addZipToSearchPath") +TEST_CASE("VirtFs1 mountZip") { VirtFs::init("."); logger = new Logger(); @@ -198,7 +198,7 @@ TEST_CASE("VirtFs1 addZipToSearchPath") SECTION("simple 1") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") != nullptr); @@ -212,9 +212,9 @@ TEST_CASE("VirtFs1 addZipToSearchPath") SECTION("simple 2") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_false)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") != nullptr); @@ -231,9 +231,9 @@ TEST_CASE("VirtFs1 addZipToSearchPath") SECTION("simple 3") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_true)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") != nullptr); @@ -250,11 +250,11 @@ TEST_CASE("VirtFs1 addZipToSearchPath") SECTION("simple 4") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_false)); - REQUIRE(VirtFs::addDirToSearchPath(prefix + "data/test", + REQUIRE(VirtFs::mountDir(prefix + "data/test", Append_false)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") != nullptr); @@ -276,11 +276,11 @@ TEST_CASE("VirtFs1 addZipToSearchPath") SECTION("simple 5") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_false)); - REQUIRE(VirtFs::addDirToSearchPath(prefix + "data/test", + REQUIRE(VirtFs::mountDir(prefix + "data/test", Append_false)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") != nullptr); @@ -317,29 +317,29 @@ TEST_CASE("VirtFs1 removeFromSearchPath") SECTION("simple 1") { - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir1")); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir1/")); + REQUIRE_THROWS(VirtFs::unmountDir("dir1")); + REQUIRE_THROWS(VirtFs::unmountDir("dir1/")); } SECTION("simple 2") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2")); - REQUIRE(VirtFs::removeDirFromSearchPath("dir1")); + REQUIRE_THROWS(VirtFs::unmountDir("dir2")); + REQUIRE(VirtFs::unmountDir("dir1")); } SECTION("simple 3") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir2//dir3", + REQUIRE(VirtFs::mountDirSilent2("dir2//dir3", Append_true)); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir3", + REQUIRE(VirtFs::mountDirSilent2("dir3", Append_false)); REQUIRE(VirtFs::getEntries().size() == 3); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2")); - REQUIRE(VirtFs::removeDirFromSearchPath("dir1")); + REQUIRE_THROWS(VirtFs::unmountDir("dir2")); + REQUIRE(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); @@ -349,7 +349,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath") REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtDirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir1")); + REQUIRE_THROWS(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::getEntries().size() == 2); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); @@ -359,8 +359,8 @@ TEST_CASE("VirtFs1 removeFromSearchPath") REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtDirEntry*>( VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3"); - REQUIRE(VirtFs::removeDirFromSearchPath("dir2/dir3")); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2/dir3" + sep)); + REQUIRE(VirtFs::unmountDir("dir2/dir3")); + REQUIRE_THROWS(VirtFs::unmountDir("dir2/dir3" + sep)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); @@ -370,17 +370,17 @@ TEST_CASE("VirtFs1 removeFromSearchPath") SECTION("simple 4") { - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir); REQUIRE(static_cast<VirtDirEntry*>( VirtFs::getEntries()[0])->userDir == "dir1"); - REQUIRE_THROWS(VirtFs::removeDirFromSearchPath("dir2")); - REQUIRE(VirtFs::removeDirFromSearchPath("dir1")); + REQUIRE_THROWS(VirtFs::unmountDir("dir2")); + REQUIRE(VirtFs::unmountDir("dir1")); REQUIRE(VirtFs::getEntries().size() == 0); - REQUIRE(VirtFs::addDirToSearchPathSilent2("dir1", + REQUIRE(VirtFs::mountDirSilent2("dir1", Append_true)); REQUIRE(VirtFs::getEntries().size() == 1); REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep); @@ -391,9 +391,9 @@ TEST_CASE("VirtFs1 removeFromSearchPath") SECTION("simple 5") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_true)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip", Append_true)); REQUIRE(VirtFs::searchEntryByRootInternal( @@ -408,7 +408,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath") prefix + "data" + sep + "test" + sep + "test2.zip"); REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") == nullptr); REQUIRE(VirtFs::searchEntryByRootInternal( @@ -421,11 +421,11 @@ TEST_CASE("VirtFs1 removeFromSearchPath") SECTION("simple 6") { - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip", Append_false)); - REQUIRE(VirtFs::addDirToSearchPath(prefix + "data/test", + REQUIRE(VirtFs::mountDir(prefix + "data/test", Append_false)); - REQUIRE(VirtFs::addZipToSearchPath(prefix + "data\\test/test2.zip", + REQUIRE(VirtFs::mountZip(prefix + "data\\test/test2.zip", Append_false)); REQUIRE(VirtFs::searchEntryByRootInternal( @@ -445,7 +445,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath") prefix + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); REQUIRE(VirtFs::searchEntryByRootInternal( prefix + "data" + sep + "test" + sep + "test.zip") == nullptr); REQUIRE(VirtFs::searchEntryByRootInternal( @@ -469,9 +469,9 @@ TEST_CASE("VirtFs1 exists") { VirtFs::init("."); logger = new Logger(); - const bool dir1 = VirtFs::addDirToSearchPathSilent("data/", + const bool dir1 = VirtFs::mountDirSilent("data/", Append_false); - VirtFs::addDirToSearchPathSilent("..\\data", + VirtFs::mountDirSilent("..\\data", Append_false); REQUIRE(VirtFs::exists("test")); @@ -486,12 +486,12 @@ TEST_CASE("VirtFs1 exists") if (dir1 == true) { - VirtFs::addDirToSearchPath("data//test", + VirtFs::mountDir("data//test", Append_false); } else { - VirtFs::addDirToSearchPathSilent("..//data\\test", + VirtFs::mountDirSilent("..//data\\test", Append_false); } @@ -506,9 +506,9 @@ TEST_CASE("VirtFs1 exists") REQUIRE(VirtFs::exists("units.xml/") == false); if (dir1 == true) - VirtFs::removeDirFromSearchPathSilent("data/test"); + VirtFs::unmountDirSilent("data/test"); else - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("../data/test"); REQUIRE(VirtFs::exists("test") == true); REQUIRE(VirtFs::exists("test/dir1")); @@ -558,9 +558,9 @@ TEST_CASE("VirtFs1 getRealDir1") const std::string sep = dirSeparator; REQUIRE(VirtFs::getRealDir(".") == ""); REQUIRE(VirtFs::getRealDir("..") == ""); - const bool dir1 = VirtFs::addDirToSearchPathSilent("data", + const bool dir1 = VirtFs::mountDirSilent("data", Append_false); - REQUIRE((dir1 || VirtFs::addDirToSearchPathSilent("../data", + REQUIRE((dir1 || VirtFs::mountDirSilent("../data", Append_false)) == true); if (dir1 == true) { @@ -584,9 +584,9 @@ TEST_CASE("VirtFs1 getRealDir1") } REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::addDirToSearchPathSilent("data/test", + VirtFs::mountDirSilent("data/test", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test", + VirtFs::mountDirSilent("../data/test", Append_false); if (dir1 == true) { @@ -610,8 +610,8 @@ TEST_CASE("VirtFs1 getRealDir1") } REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::removeDirFromSearchPathSilent("data/test"); - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("data/test"); + VirtFs::unmountDirSilent("../data/test"); if (dir1 == true) { @@ -627,8 +627,8 @@ TEST_CASE("VirtFs1 getRealDir1") } REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); VirtFs::deinit(); delete2(logger); } @@ -642,7 +642,7 @@ TEST_CASE("VirtFs1 getRealDir2") std::string prefix("data" + sep + "test" + sep); if (Files::existsLocal(name) == false) prefix = ".." + sep + prefix; - VirtFs::addZipToSearchPath(prefix + "test2.zip", + VirtFs::mountZip(prefix + "test2.zip", Append_false); REQUIRE(VirtFs::getRealDir(".") == ""); @@ -653,7 +653,7 @@ TEST_CASE("VirtFs1 getRealDir2") prefix + "test2.zip"); REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::addZipToSearchPath(prefix + "test.zip", + VirtFs::mountZip(prefix + "test.zip", Append_false); REQUIRE(VirtFs::getRealDir("dir//dye.png") == prefix + "test2.zip"); @@ -663,7 +663,7 @@ TEST_CASE("VirtFs1 getRealDir2") prefix + "test.zip"); REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::removeZipFromSearchPath(prefix + "test.zip"); + VirtFs::unmountZip(prefix + "test.zip"); REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") == ""); REQUIRE(VirtFs::getRealDir("test.txt") == prefix + "test2.zip"); @@ -671,7 +671,7 @@ TEST_CASE("VirtFs1 getRealDir2") prefix + "test2.zip"); REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::removeZipFromSearchPath(prefix + "test2.zip"); + VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); delete2(logger); } @@ -692,9 +692,9 @@ TEST_CASE("VirtFs1 enumerateFiles1") VirtFs::init("."); logger = new Logger; - VirtFs::addDirToSearchPathSilent("data", + VirtFs::mountDirSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", + VirtFs::mountDirSilent("../data", Append_false); VirtList *list = nullptr; @@ -726,8 +726,8 @@ TEST_CASE("VirtFs1 enumerateFiles1") REQUIRE(list->names.size() == cnt1); VirtFs::freeList(list); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); VirtFs::deinit(); delete2(logger); } @@ -737,9 +737,9 @@ TEST_CASE("VirtFs1 enumerateFiles2") VirtFs::init("."); logger = new Logger; - VirtFs::addDirToSearchPathSilent("data/test/dir1", + VirtFs::mountDirSilent("data/test/dir1", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test/dir1", + VirtFs::mountDirSilent("../data/test/dir1", Append_false); VirtList *list = nullptr; @@ -759,13 +759,13 @@ TEST_CASE("VirtFs1 enumerateFiles3") VirtFs::init("."); logger = new Logger; - VirtFs::addDirToSearchPathSilent("data/test/dir1", + VirtFs::mountDirSilent("data/test/dir1", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test/dir1", + VirtFs::mountDirSilent("../data/test/dir1", Append_false); - VirtFs::addDirToSearchPathSilent("data/test/dir2", + VirtFs::mountDirSilent("data/test/dir2", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test/dir2", + VirtFs::mountDirSilent("../data/test/dir2", Append_false); VirtList *list = nullptr; @@ -789,7 +789,7 @@ TEST_CASE("VirtFsZip enumerateFiles4") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test.zip", + VirtFs::mountZip(prefix + "test.zip", Append_false); VirtList *list = nullptr; @@ -800,7 +800,7 @@ TEST_CASE("VirtFsZip enumerateFiles4") REQUIRE(inList(list, "hide.png")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "test.zip"); + VirtFs::unmountZip(prefix + "test.zip"); VirtFs::deinit(); delete2(logger); } @@ -814,9 +814,9 @@ TEST_CASE("VirtFsZip enumerateFiles5") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test.zip", + VirtFs::mountZip(prefix + "test.zip", Append_true); - VirtFs::addZipToSearchPath(prefix + "test2.zip", + VirtFs::mountZip(prefix + "test2.zip", Append_true); VirtList *list = nullptr; @@ -835,8 +835,8 @@ TEST_CASE("VirtFsZip enumerateFiles5") REQUIRE(inList(list, "dye.png")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "test.zip"); - VirtFs::removeZipFromSearchPath(prefix + "test2.zip"); + VirtFs::unmountZip(prefix + "test.zip"); + VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); delete2(logger); } @@ -850,7 +850,7 @@ TEST_CASE("VirtFsZip enumerateFiles6") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test.zip", + VirtFs::mountZip(prefix + "test.zip", Append_false); VirtList *list = nullptr; @@ -860,7 +860,7 @@ TEST_CASE("VirtFsZip enumerateFiles6") REQUIRE(inList(list, "dir")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "test.zip"); + VirtFs::unmountZip(prefix + "test.zip"); VirtFs::deinit(); delete2(logger); } @@ -874,7 +874,7 @@ TEST_CASE("VirtFsZip enumerateFiles7") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test2.zip", + VirtFs::mountZip(prefix + "test2.zip", Append_false); VirtList *list = nullptr; @@ -887,7 +887,7 @@ TEST_CASE("VirtFsZip enumerateFiles7") REQUIRE(inList(list, "units.xml")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "test2.zip"); + VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); delete2(logger); } @@ -901,9 +901,9 @@ TEST_CASE("VirtFsZip enumerateFiles8") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); - VirtFs::addDirToSearchPathSilent(prefix + "data/test", + VirtFs::mountDirSilent(prefix + "data/test", Append_false); VirtList *list = nullptr; @@ -918,8 +918,8 @@ TEST_CASE("VirtFsZip enumerateFiles8") REQUIRE(inList(list, "units.xml")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDir(prefix + "data/test"); VirtFs::deinit(); delete2(logger); } @@ -933,7 +933,7 @@ TEST_CASE("VirtFs1 isDirectory1") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data", + VirtFs::mountDir(prefix + "data", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); @@ -957,7 +957,7 @@ TEST_CASE("VirtFs1 isDirectory1") REQUIRE(VirtFs::isDirectory("testQ/") == false); REQUIRE(VirtFs::isDirectory("testQ//") == false); - VirtFs::addDirToSearchPath(prefix + "data/test", + VirtFs::mountDir(prefix + "data/test", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); @@ -971,7 +971,7 @@ TEST_CASE("VirtFs1 isDirectory1") REQUIRE(VirtFs::isDirectory("test/dir1") == true); REQUIRE(VirtFs::isDirectory("test\\dir1") == true); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountDir(prefix + "data/test"); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("test/units123.xml") == false); @@ -983,7 +983,7 @@ TEST_CASE("VirtFs1 isDirectory1") REQUIRE(VirtFs::isDirectory("testQ") == false); REQUIRE(VirtFs::isDirectory("test/dir1") == true); - VirtFs::removeDirFromSearchPathSilent(prefix + "data"); + VirtFs::unmountDirSilent(prefix + "data"); VirtFs::deinit(); delete2(logger); } @@ -997,7 +997,7 @@ TEST_CASE("VirtFs1 isDirectory2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); @@ -1021,7 +1021,7 @@ TEST_CASE("VirtFs1 isDirectory2") REQUIRE(VirtFs::isDirectory("testQ/") == false); REQUIRE(VirtFs::isDirectory("testQ//") == false); - VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + VirtFs::mountZip(prefix + "data/test/test.zip", Append_false); REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); @@ -1045,7 +1045,7 @@ TEST_CASE("VirtFs1 isDirectory2") REQUIRE(VirtFs::isDirectory("testQ/") == false); REQUIRE(VirtFs::isDirectory("testQ//") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); REQUIRE(VirtFs::isDirectory("dir2/units.xml") == false); REQUIRE(VirtFs::isDirectory("dir2/units.xml/") == false); @@ -1068,7 +1068,7 @@ TEST_CASE("VirtFs1 isDirectory2") REQUIRE(VirtFs::isDirectory("testQ/") == false); REQUIRE(VirtFs::isDirectory("testQ//") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); VirtFs::deinit(); delete2(logger); } @@ -1082,7 +1082,7 @@ TEST_CASE("VirtFs1 openRead1") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data", + VirtFs::mountDir(prefix + "data", Append_false); VirtFile *file = nullptr; @@ -1102,7 +1102,7 @@ TEST_CASE("VirtFs1 openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::addDirToSearchPath(prefix + "data/test", + VirtFs::mountDir(prefix + "data/test", Append_false); file = VirtFs::openRead("test/units.xml"); @@ -1118,7 +1118,7 @@ TEST_CASE("VirtFs1 openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountDir(prefix + "data/test"); file = VirtFs::openRead("test/units.xml"); REQUIRE(file != nullptr); @@ -1132,7 +1132,7 @@ TEST_CASE("VirtFs1 openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::removeDirFromSearchPath(prefix + "data"); + VirtFs::unmountDir(prefix + "data"); VirtFs::deinit(); delete2(logger); } @@ -1146,7 +1146,7 @@ TEST_CASE("VirtFs1 openRead2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test2.zip", + VirtFs::mountZip(prefix + "test2.zip", Append_false); VirtFile *file = nullptr; @@ -1170,7 +1170,7 @@ TEST_CASE("VirtFs1 openRead2") file = VirtFs::openRead("dir//brimmedhat.png"); REQUIRE(file == nullptr); - VirtFs::addZipToSearchPath(prefix + "test.zip", + VirtFs::mountZip(prefix + "test.zip", Append_false); file = VirtFs::openRead("dir2/units.xml"); @@ -1191,7 +1191,7 @@ TEST_CASE("VirtFs1 openRead2") REQUIRE(file != nullptr); VirtFs::close(file); - VirtFs::removeZipFromSearchPath(prefix + "test.zip"); + VirtFs::unmountZip(prefix + "test.zip"); file = VirtFs::openRead("dir2/units.xml"); REQUIRE(file != nullptr); @@ -1210,7 +1210,7 @@ TEST_CASE("VirtFs1 openRead2") file = VirtFs::openRead("dir/brimmedhat.png"); REQUIRE(file == nullptr); - VirtFs::removeZipFromSearchPath(prefix + "test2.zip"); + VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); delete2(logger); @@ -1225,7 +1225,7 @@ TEST_CASE("VirtFs1 permitLinks") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data", + VirtFs::mountDir(prefix + "data", Append_false); const int cnt1 = VirtFs::exists("test/test2.txt") ? 26 : 25; @@ -1250,7 +1250,7 @@ TEST_CASE("VirtFs1 permitLinks") removeTemp(list); REQUIRE(list.size() == cnt1); - VirtFs::removeDirFromSearchPathSilent(prefix + "data"); + VirtFs::unmountDirSilent(prefix + "data"); VirtFs::deinit(); delete2(logger); } @@ -1264,7 +1264,7 @@ TEST_CASE("VirtFs1 read1") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data", + VirtFs::mountDir(prefix + "data", Append_false); VirtFile *file = VirtFs::openRead("test/test.txt"); @@ -1292,7 +1292,7 @@ TEST_CASE("VirtFs1 read1") VirtFs::close(file); free(buffer); - VirtFs::removeDirFromSearchPath(prefix + "data"); + VirtFs::unmountDir(prefix + "data"); VirtFs::deinit(); delete2(logger); } @@ -1306,7 +1306,7 @@ TEST_CASE("VirtFs1 read2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "test2.zip", + VirtFs::mountZip(prefix + "test2.zip", Append_false); VirtFile *file = nullptr; void *restrict buffer = nullptr; @@ -1423,7 +1423,7 @@ TEST_CASE("VirtFs1 read2") VirtFs::close(file); free(buffer); - VirtFs::removeZipFromSearchPath(prefix + "test2.zip"); + VirtFs::unmountZip(prefix + "test2.zip"); VirtFs::deinit(); delete2(logger); } diff --git a/src/fs/virtfs_unittest.cc b/src/fs/virtfs_unittest.cc index b3f07daa1..0ef26ae9f 100644 --- a/src/fs/virtfs_unittest.cc +++ b/src/fs/virtfs_unittest.cc @@ -53,8 +53,8 @@ TEST_CASE("VirtFs getUserDir") TEST_CASE("VirtFs exists1") { logger = new Logger(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); REQUIRE(VirtFs::exists("test") == true); REQUIRE(VirtFs::exists("test/dir1") == true); @@ -64,8 +64,8 @@ TEST_CASE("VirtFs exists1") REQUIRE(VirtFs::exists("tesQ/units.xml") == false); REQUIRE(VirtFs::exists("units.xml") == false); - VirtFs::addDirToSearchPathSilent("data/test", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test", Append_false); + VirtFs::mountDirSilent("data/test", Append_false); + VirtFs::mountDirSilent("../data/test", Append_false); REQUIRE(VirtFs::exists("test") == true); REQUIRE(VirtFs::exists("test/dir1") == true); @@ -75,8 +75,8 @@ TEST_CASE("VirtFs exists1") REQUIRE(VirtFs::exists("tesQ/units.xml") == false); REQUIRE(VirtFs::exists("units.xml") == true); - VirtFs::removeDirFromSearchPathSilent("data/test"); - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("data/test"); + VirtFs::unmountDirSilent("../data/test"); REQUIRE(VirtFs::exists("test") == true); REQUIRE(VirtFs::exists("test/dir1") == true); @@ -86,8 +86,8 @@ TEST_CASE("VirtFs exists1") REQUIRE(VirtFs::exists("tesQ/units.xml") == false); REQUIRE(VirtFs::exists("units.xml") == false); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } @@ -99,7 +99,7 @@ TEST_CASE("VirtFs exists2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); REQUIRE(VirtFs::exists("test") == false); REQUIRE(VirtFs::exists("test/units.xml") == false); @@ -111,7 +111,7 @@ TEST_CASE("VirtFs exists2") REQUIRE(VirtFs::exists("units.xml.") == false); REQUIRE(VirtFs::exists("units.xml2") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -123,8 +123,8 @@ TEST_CASE("VirtFs exists3") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); REQUIRE(VirtFs::exists("test") == false); REQUIRE(VirtFs::exists("test/units.xml") == false); @@ -138,8 +138,8 @@ TEST_CASE("VirtFs exists3") REQUIRE(VirtFs::exists("dir2/2") == false); REQUIRE(VirtFs::exists("dir2/paths.xml")); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -151,8 +151,8 @@ TEST_CASE("VirtFs exists4") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", Append_false); - VirtFs::addDirToSearchPathSilent(prefix + "data/test", Append_false); + VirtFs::mountZip(prefix + "data/test/test.zip", Append_false); + VirtFs::mountDirSilent(prefix + "data/test", Append_false); REQUIRE(VirtFs::exists("test") == false); REQUIRE(VirtFs::exists("test/units.xml") == false); @@ -170,8 +170,8 @@ TEST_CASE("VirtFs exists4") REQUIRE(VirtFs::exists("dir2/file2.txt")); REQUIRE(VirtFs::exists("dir2/file3.txt") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); - VirtFs::removeDirFromSearchPathSilent(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); + VirtFs::unmountDirSilent(prefix + "data/test"); delete2(logger); } @@ -231,8 +231,8 @@ TEST_CASE("VirtFs enumerateFiles1") { logger = new Logger; - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); VirtList *list = nullptr; @@ -263,8 +263,8 @@ TEST_CASE("VirtFs enumerateFiles1") REQUIRE(list->names.size() == 0); VirtFs::freeList(list); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } @@ -272,9 +272,9 @@ TEST_CASE("VirtFs enumerateFiles2") { logger = new Logger; - VirtFs::addDirToSearchPathSilent("data/test/dir1", + VirtFs::mountDirSilent("data/test/dir1", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test/dir1", + VirtFs::mountDirSilent("../data/test/dir1", Append_false); VirtList *list = nullptr; @@ -284,8 +284,8 @@ TEST_CASE("VirtFs enumerateFiles2") REQUIRE(list->names.size() == 5); VirtFs::freeList(list); - VirtFs::removeDirFromSearchPathSilent("data/test/dir1"); - VirtFs::removeDirFromSearchPathSilent("../data/test/dir1"); + VirtFs::unmountDirSilent("data/test/dir1"); + VirtFs::unmountDirSilent("../data/test/dir1"); delete2(logger); } @@ -297,7 +297,7 @@ TEST_CASE("VirtFs enumerateFiles3") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test.zip", + VirtFs::mountZip(prefix + "data/test/test.zip", Append_false); VirtList *list = nullptr; @@ -307,7 +307,7 @@ TEST_CASE("VirtFs enumerateFiles3") REQUIRE(inList(list, "dir")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test.zip"); + VirtFs::unmountZip(prefix + "data/test/test.zip"); delete2(logger); } @@ -319,7 +319,7 @@ TEST_CASE("VirtFs enumerateFiles4") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); VirtList *list = nullptr; @@ -332,7 +332,7 @@ TEST_CASE("VirtFs enumerateFiles4") REQUIRE(inList(list, "units.xml")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -344,9 +344,9 @@ TEST_CASE("VirtFs enumerateFiles5") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); - VirtFs::addDirToSearchPathSilent(prefix + "data/test", Append_false); + VirtFs::mountDirSilent(prefix + "data/test", Append_false); VirtList *list = nullptr; @@ -359,16 +359,16 @@ TEST_CASE("VirtFs enumerateFiles5") REQUIRE(inList(list, "units.xml")); VirtFs::freeList(list); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPathSilent(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDirSilent(prefix + "data/test"); delete2(logger); } TEST_CASE("VirtFs isDirectory1") { logger = new Logger(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("test/units.xml/") == false); @@ -391,8 +391,8 @@ TEST_CASE("VirtFs isDirectory1") REQUIRE(VirtFs::isDirectory("testQ/") == false); REQUIRE(VirtFs::isDirectory("testQ//") == false); - VirtFs::addDirToSearchPathSilent("data/test", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test", Append_false); + VirtFs::mountDirSilent("data/test", Append_false); + VirtFs::mountDirSilent("../data/test", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("test/units.xml/") == false); @@ -404,8 +404,8 @@ TEST_CASE("VirtFs isDirectory1") REQUIRE(VirtFs::isDirectory("testQ") == false); REQUIRE(VirtFs::isDirectory("test/dir1") == true); - VirtFs::removeDirFromSearchPathSilent("data/test"); - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("data/test"); + VirtFs::unmountDirSilent("../data/test"); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("test/units123.xml") == false); @@ -417,8 +417,8 @@ TEST_CASE("VirtFs isDirectory1") REQUIRE(VirtFs::isDirectory("testQ") == false); REQUIRE(VirtFs::isDirectory("test/dir1") == true); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } @@ -430,7 +430,7 @@ TEST_CASE("VirtFs isDirectory2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("dir") == true); @@ -440,7 +440,7 @@ TEST_CASE("VirtFs isDirectory2") REQUIRE(VirtFs::isDirectory("dir3") == false); REQUIRE(VirtFs::isDirectory("test.txt") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -452,8 +452,8 @@ TEST_CASE("VirtFs isDirectory3") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data", Append_false); - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountDir(prefix + "data", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); REQUIRE(VirtFs::isDirectory("test/units.xml") == false); REQUIRE(VirtFs::isDirectory("test")); @@ -466,16 +466,16 @@ TEST_CASE("VirtFs isDirectory3") REQUIRE(VirtFs::isDirectory("test.txt") == false); REQUIRE(VirtFs::isDirectory("dir/hide.png") == false); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDir(prefix + "data"); delete2(logger); } TEST_CASE("VirtFs openRead1") { logger = new Logger(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); VirtFile *file = nullptr; @@ -493,8 +493,8 @@ TEST_CASE("VirtFs openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::addDirToSearchPathSilent("data/test", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test", Append_false); + VirtFs::mountDirSilent("data/test", Append_false); + VirtFs::mountDirSilent("../data/test", Append_false); file = VirtFs::openRead("test/units.xml"); REQUIRE(file != nullptr); @@ -511,8 +511,8 @@ TEST_CASE("VirtFs openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::removeDirFromSearchPathSilent("data/test"); - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("data/test"); + VirtFs::unmountDirSilent("../data/test"); file = VirtFs::openRead("test/units.xml"); REQUIRE(file != nullptr); @@ -528,8 +528,8 @@ TEST_CASE("VirtFs openRead1") file = VirtFs::openRead("testQ"); REQUIRE(file == nullptr); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } @@ -541,7 +541,7 @@ TEST_CASE("VirtFs openRead2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); VirtFile *file = nullptr; @@ -557,7 +557,7 @@ TEST_CASE("VirtFs openRead2") REQUIRE(file != nullptr); VirtFs::close(file); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -569,8 +569,8 @@ TEST_CASE("VirtFs openRead3") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); - VirtFs::addDirToSearchPath(prefix + "data/test", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountDir(prefix + "data/test", Append_false); VirtFile *file = nullptr; @@ -591,8 +591,8 @@ TEST_CASE("VirtFs openRead3") file = VirtFs::openRead("dir/dye.pn_"); REQUIRE(file == nullptr); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDir(prefix + "data/test"); delete2(logger); } @@ -602,8 +602,8 @@ TEST_CASE("VirtFs getRealDir1") const std::string sep = dirSeparator; REQUIRE(VirtFs::getRealDir(".") == ""); REQUIRE(VirtFs::getRealDir("..") == ""); - const bool dir1 = VirtFs::addDirToSearchPathSilent("data", Append_false); - REQUIRE((dir1 || VirtFs::addDirToSearchPathSilent("../data", Append_false)) + const bool dir1 = VirtFs::mountDirSilent("data", Append_false); + REQUIRE((dir1 || VirtFs::mountDirSilent("../data", Append_false)) == true); if (dir1 == true) { @@ -619,8 +619,8 @@ TEST_CASE("VirtFs getRealDir1") } REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::addDirToSearchPathSilent("data/test", Append_false); - VirtFs::addDirToSearchPathSilent("../data/test", Append_false); + VirtFs::mountDirSilent("data/test", Append_false); + VirtFs::mountDirSilent("../data/test", Append_false); if (dir1 == true) { REQUIRE(VirtFs::getRealDir("test") == "data"); @@ -641,7 +641,7 @@ TEST_CASE("VirtFs getRealDir1") if (dir1 == true) { - VirtFs::addZipToSearchPath("data/test/test.zip", Append_false); + VirtFs::mountZip("data/test/test.zip", Append_false); REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") == "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getRealDir("hide.png") == @@ -649,15 +649,15 @@ TEST_CASE("VirtFs getRealDir1") } else { - VirtFs::addZipToSearchPath("../data/test/test.zip", Append_false); + VirtFs::mountZip("../data/test/test.zip", Append_false); REQUIRE(VirtFs::getRealDir("dir/brimmedhat.png") == ".." + sep + "data" + sep + "test" + sep + "test.zip"); REQUIRE(VirtFs::getRealDir("hide.png") == ".." + sep + "data" + sep + "test"); } - VirtFs::removeDirFromSearchPathSilent("data/test"); - VirtFs::removeDirFromSearchPathSilent("../data/test"); + VirtFs::unmountDirSilent("data/test"); + VirtFs::unmountDirSilent("../data/test"); if (dir1 == true) { @@ -678,12 +678,12 @@ TEST_CASE("VirtFs getRealDir1") REQUIRE(VirtFs::exists("dir/hide.png")); REQUIRE(VirtFs::getRealDir("zzz") == ""); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); if (dir1 == true) - VirtFs::removeZipFromSearchPath("data/test/test.zip"); + VirtFs::unmountZip("data/test/test.zip"); else - VirtFs::removeZipFromSearchPath("../data/test/test.zip"); + VirtFs::unmountZip("../data/test/test.zip"); delete2(logger); } @@ -696,9 +696,9 @@ TEST_CASE("VirtFs getrealDir2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); - VirtFs::addDirToSearchPath(prefix + "data/test", Append_false); - VirtFs::addDirToSearchPath(prefix + "data", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountDir(prefix + "data/test", Append_false); + VirtFs::mountDir(prefix + "data", Append_false); REQUIRE(VirtFs::getRealDir("zzz") == ""); @@ -711,17 +711,17 @@ TEST_CASE("VirtFs getrealDir2") REQUIRE(VirtFs::getRealDir("dir/1//test.txt") == prefix + "data" + sep + "test" + sep + "test2.zip"); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); - VirtFs::removeDirFromSearchPath(prefix + "data"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDir(prefix + "data/test"); + VirtFs::unmountDir(prefix + "data"); delete2(logger); } TEST_CASE("VirtFs permitLinks") { logger = new Logger(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); const int cnt1 = VirtFs::exists("test/test2.txt") ? 26 : 25; const int cnt2 = 26; @@ -745,16 +745,16 @@ TEST_CASE("VirtFs permitLinks") removeTemp(list); REQUIRE(list.size() == cnt1); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } TEST_CASE("VirtFs read1") { logger = new Logger(); - VirtFs::addDirToSearchPathSilent("data", Append_false); - VirtFs::addDirToSearchPathSilent("../data", Append_false); + VirtFs::mountDirSilent("data", Append_false); + VirtFs::mountDirSilent("../data", Append_false); VirtFile *file = VirtFs::openRead("test/test.txt"); REQUIRE(file != nullptr); @@ -781,8 +781,8 @@ TEST_CASE("VirtFs read1") VirtFs::close(file); free(buffer); - VirtFs::removeDirFromSearchPathSilent("data"); - VirtFs::removeDirFromSearchPathSilent("../data"); + VirtFs::unmountDirSilent("data"); + VirtFs::unmountDirSilent("../data"); delete2(logger); } @@ -794,7 +794,7 @@ TEST_CASE("VirtFs read2") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); VirtFile *file = VirtFs::openRead("dir2/test.txt"); REQUIRE(file != nullptr); @@ -821,7 +821,7 @@ TEST_CASE("VirtFs read2") VirtFs::close(file); free(buffer); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); delete2(logger); } @@ -833,8 +833,8 @@ TEST_CASE("VirtFs read3") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test2.zip", Append_false); - VirtFs::addDirToSearchPath(prefix + "data", Append_false); + VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false); + VirtFs::mountDir(prefix + "data", Append_false); VirtFile *file = VirtFs::openRead("dir2/test.txt"); REQUIRE(file != nullptr); @@ -861,8 +861,8 @@ TEST_CASE("VirtFs read3") VirtFs::close(file); free(buffer); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test2.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data"); + VirtFs::unmountZip(prefix + "data/test/test2.zip"); + VirtFs::unmountDir(prefix + "data"); delete2(logger); } @@ -874,8 +874,8 @@ TEST_CASE("VirtFs read4") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addDirToSearchPath(prefix + "data/test", Append_true); - VirtFs::addZipToSearchPath(prefix + "data/test/test5.zip", Append_true); + VirtFs::mountDir(prefix + "data/test", Append_true); + VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true); VirtFile *file = VirtFs::openRead("dir1/file1.txt"); REQUIRE(file != nullptr); @@ -902,8 +902,8 @@ TEST_CASE("VirtFs read4") VirtFs::close(file); free(buffer); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test5.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test5.zip"); + VirtFs::unmountDir(prefix + "data/test"); delete2(logger); } @@ -915,8 +915,8 @@ TEST_CASE("VirtFs read5") if (Files::existsLocal(name) == false) prefix = "../" + prefix; - VirtFs::addZipToSearchPath(prefix + "data/test/test5.zip", Append_true); - VirtFs::addDirToSearchPath(prefix + "data/test", Append_true); + VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true); + VirtFs::mountDir(prefix + "data/test", Append_true); VirtFile *file = VirtFs::openRead("dir1/file1.txt"); REQUIRE(file != nullptr); @@ -943,7 +943,7 @@ TEST_CASE("VirtFs read5") VirtFs::close(file); free(buffer); - VirtFs::removeZipFromSearchPath(prefix + "data/test/test5.zip"); - VirtFs::removeDirFromSearchPath(prefix + "data/test"); + VirtFs::unmountZip(prefix + "data/test/test5.zip"); + VirtFs::unmountDir(prefix + "data/test"); delete2(logger); } diff --git a/src/fs/virtfstools.cpp b/src/fs/virtfstools.cpp index 0b434a340..9ba8c6683 100644 --- a/src/fs/virtfstools.cpp +++ b/src/fs/virtfstools.cpp @@ -83,7 +83,7 @@ namespace VirtFs { const std::string file = path + str; const std::string realPath = VirtFs::getRealDir(file); - VirtFs::addZipToSearchPath(std::string(realPath).append( + VirtFs::mountZip(std::string(realPath).append( dirSeparator).append(file), append); } } @@ -103,7 +103,7 @@ namespace VirtFs { const std::string file = path + str; const std::string realPath = VirtFs::getRealDir(file); - VirtFs::removeZipFromSearchPath(std::string( + VirtFs::unmountZip(std::string( realPath).append( dirSeparator).append( file)); |