summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/files_unittest.cc12
-rw-r--r--src/fs/virtfs/virtfs.cpp18
2 files changed, 30 insertions, 0 deletions
diff --git a/src/fs/files_unittest.cc b/src/fs/files_unittest.cc
index 7b4c6ca33..69956ddb3 100644
--- a/src/fs/files_unittest.cc
+++ b/src/fs/files_unittest.cc
@@ -66,6 +66,8 @@ TEST_CASE("Files renameFile")
delete [] buf;
delete [] buf2;
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -81,6 +83,8 @@ TEST_CASE("Files existsLocal")
REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help/about1.txt")));
REQUIRE_FALSE(Files::existsLocal(VirtFs::getPath("help1/about.txt")));
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -95,6 +99,8 @@ TEST_CASE("Files loadTextFileString")
REQUIRE(VirtFs::loadTextFileString("test/simplefile.txt") ==
"this is test \nfile.");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -113,6 +119,8 @@ TEST_CASE("Files loadTextFile")
REQUIRE(lines[0] == "this is test ");
REQUIRE(lines[1] == "file.");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -132,6 +140,8 @@ TEST_CASE("Files saveTextFile")
::remove((dir + "/tempfile.txt").c_str());
REQUIRE(data == "test line\ntext line2\n");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
@@ -162,6 +172,8 @@ TEST_CASE("Files getFilesInDir")
REQUIRE(list[3] == "perserver/default/features.xml");
REQUIRE(list[4] == "perserver/default/weapons.xml");
ResourceManager::deleteInstance();
+ VirtFs::removeDirFromSearchPath("data");
+ VirtFs::removeDirFromSearchPath("../data");
delete2(logger);
// VirtFs::deinit();
}
diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp
index 3d223ccba..f9fcdcf8b 100644
--- a/src/fs/virtfs/virtfs.cpp
+++ b/src/fs/virtfs/virtfs.cpp
@@ -144,23 +144,41 @@ namespace VirtFs
bool addDirToSearchPath(const std::string &restrict newDir,
const Append append)
{
+#ifdef UNITTESTS
+ return VirtFsDir::addToSearchPathSilent(newDir,
+ append,
+ SkipError_false);
+#else // UNITTESTS
return VirtFsDir::addToSearchPath(newDir, append);
+#endif // UNITTESTS
}
bool removeDirFromSearchPath(const std::string &restrict oldDir)
{
+#ifdef UNITTESTS
+ return VirtFsDir::removeFromSearchPathSilent(oldDir);
+#else // UNITTESTS
return VirtFsDir::removeFromSearchPath(oldDir);
+#endif // UNITTESTS
}
bool addZipToSearchPath(const std::string &restrict newDir,
const Append append)
{
+#ifdef UNITTESTS
+ return VirtFsZip::addToSearchPathSilent(newDir, append);
+#else // UNITTESTS
return VirtFsZip::addToSearchPath(newDir, append);
+#endif // UNITTESTS
}
bool removeZipFromSearchPath(const std::string &restrict oldDir)
{
+#ifdef UNITTESTS
+ return VirtFsZip::removeFromSearchPathSilent(oldDir);
+#else // UNITTESTS
return VirtFsZip::removeFromSearchPath(oldDir);
+#endif // UNITTESTS
}
std::string getRealDir(std::string filename)