summaryrefslogtreecommitdiff
path: root/src/fs/virtfs
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-16 22:41:56 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-16 22:41:56 +0300
commit8e0bd85107f57e900658129f9cfbded0866f0883 (patch)
tree05dab2c86bcf6d079c69ecb40dea258a6572fbbe /src/fs/virtfs
parentba71181d5e6fd35083a9e7a86c8e1a9592581398 (diff)
downloadplus-8e0bd85107f57e900658129f9cfbded0866f0883.tar.gz
plus-8e0bd85107f57e900658129f9cfbded0866f0883.tar.bz2
plus-8e0bd85107f57e900658129f9cfbded0866f0883.tar.xz
plus-8e0bd85107f57e900658129f9cfbded0866f0883.zip
Improve a bit subDir empty check in virtfs.
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r--src/fs/virtfs/fs.cpp50
-rw-r--r--src/fs/virtfs/fszip.cpp18
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc224
3 files changed, 178 insertions, 114 deletions
diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp
index d8f815562..02f1910be 100644
--- a/src/fs/virtfs/fs.cpp
+++ b/src/fs/virtfs/fs.cpp
@@ -351,8 +351,15 @@ namespace VirtFs
std::string rootDir = newDir;
if (findLast(rootDir, std::string(dirSeparator)) == false)
rootDir += dirSeparator;
- if (findLast(subDir, std::string(dirSeparator)) == false)
+ if (subDir == dirSeparator)
+ {
+ subDir.clear();
+ }
+ else if (!subDir.empty() &&
+ findLast(subDir, std::string(dirSeparator)) == false)
+ {
subDir += dirSeparator;
+ }
const FsEntry *const entry = searchByRootInternal(rootDir, subDir);
if (entry != nullptr)
{
@@ -404,7 +411,7 @@ namespace VirtFs
newDir.c_str());
return false;
}
- return mountDirInternal(newDir, dirSeparator, append);
+ return mountDirInternal(newDir, std::string(), append);
}
bool mountDirSilent2(std::string newDir,
@@ -432,7 +439,7 @@ namespace VirtFs
logger->log("VirtFs::mount directory not exists: %s",
newDir.c_str());
}
- return mountDirInternal(newDir, dirSeparator,append);
+ return mountDirInternal(newDir, std::string() ,append);
}
bool mountDirSilentTest2(std::string newDir,
@@ -455,8 +462,15 @@ namespace VirtFs
{
if (findLast(oldDir, std::string(dirSeparator)) == false)
oldDir += dirSeparator;
- if (findLast(subDir, std::string(dirSeparator)) == false)
+ if (subDir == dirSeparator)
+ {
+ subDir.clear();
+ }
+ else if (!subDir.empty() &&
+ findLast(subDir, std::string(dirSeparator)) == false)
+ {
subDir += dirSeparator;
+ }
FOR_EACH (std::vector<FsEntry*>::iterator, it, mEntries)
{
FsEntry *const entry = *it;
@@ -483,7 +497,7 @@ namespace VirtFs
reportAlways("Called unmount with zip archive");
return false;
}
- if (unmountDirInternal(oldDir, dirSeparator) == false)
+ if (unmountDirInternal(oldDir, std::string()) == false)
{
reportAlways("VirtFs::unmountDir not exists: %s",
oldDir.c_str());
@@ -519,7 +533,7 @@ namespace VirtFs
reportAlways("Called unmount with zip archive");
return false;
}
- if (unmountDirInternal(oldDir, dirSeparator) == false)
+ if (unmountDirInternal(oldDir, std::string()) == false)
{
logger->log("VirtFs::unmountDir not exists: %s",
oldDir.c_str());
@@ -563,14 +577,14 @@ namespace VirtFs
"zip archive");
return false;
}
- if (searchByRootInternal(newDir, dirSeparator) != nullptr)
+ if (searchByRootInternal(newDir, std::string()) != nullptr)
{
reportAlways("FsZip::mount already exists: %s",
newDir.c_str());
return false;
}
ZipEntry *const entry = new ZipEntry(newDir,
- dirSeparator,
+ std::string(),
FsZip::getFuncs());
if (ZipReader::readArchiveInfo(entry) == false)
{
@@ -601,8 +615,15 @@ namespace VirtFs
return false;
}
prepareFsPath(subDir);
- if (findLast(subDir, std::string(dirSeparator)) == false)
+ if (subDir == dirSeparator)
+ {
+ subDir.clear();
+ }
+ else if (!subDir.empty() &&
+ findLast(subDir, std::string(dirSeparator)) == false)
+ {
subDir += dirSeparator;
+ }
if (searchByRootInternal(newDir, subDir) != nullptr)
{
reportAlways("FsZip::mount already exists: %s",
@@ -636,7 +657,7 @@ namespace VirtFs
FsEntry *const entry = *it;
if (entry->root == oldDir &&
entry->type == FsEntryType::Zip &&
- entry->subDir == dirSeparator)
+ entry->subDir == std::string())
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(
entry);
@@ -662,8 +683,15 @@ namespace VirtFs
return false;
}
prepareFsPath(subDir);
- if (findLast(subDir, std::string(dirSeparator)) == false)
+ if (subDir == dirSeparator)
+ {
+ subDir.clear();
+ }
+ else if (!subDir.empty() &&
+ findLast(subDir, std::string(dirSeparator)) == false)
+ {
subDir += dirSeparator;
+ }
FOR_EACH (std::vector<FsEntry*>::iterator, it, mEntries)
{
FsEntry *const entry = *it;
diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp
index 068b7ee45..d70df7749 100644
--- a/src/fs/virtfs/fszip.cpp
+++ b/src/fs/virtfs/fszip.cpp
@@ -95,7 +95,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
{
filename = pathJoin(subDir, filename);
dirName = pathJoin(subDir, dirName);
@@ -129,7 +129,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
{
filename = pathJoin(subDir, filename);
dirName = pathJoin(subDir, dirName);
@@ -157,7 +157,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
const std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
dirName = pathJoin(subDir, dirName);
if (dirName == dirSeparator)
{
@@ -220,7 +220,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
const std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
dirName = pathJoin(subDir, dirName);
if (dirName == dirSeparator)
{
@@ -319,7 +319,7 @@ namespace FsZip
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
const std::string subDir = zipEntry->subDir;
std::string dirNameFull;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
dirNameFull = pathJoin(subDir, dirName);
else
dirNameFull = dirName;
@@ -419,7 +419,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
const std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
dirName = pathJoin(subDir, dirName);
if (dirName == dirSeparator)
{
@@ -517,7 +517,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
dirName = pathJoin(subDir, dirName);
FOR_EACH (std::vector<std::string>::const_iterator,
it2,
@@ -542,7 +542,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
filename = pathJoin(subDir, filename);
FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
it2,
@@ -675,7 +675,7 @@ namespace FsZip
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
const std::string subDir = zipEntry->subDir;
- if (subDir != dirSeparator)
+ if (!subDir.empty())
filename = pathJoin(subDir, filename);
FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
it2,
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index a2c7f8590..15ba6c1e7 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -39,7 +39,7 @@ TEST_CASE("VirtFs1 getEntries")
{
VirtFs::init(".");
REQUIRE(VirtFs::getEntries().empty());
- REQUIRE(VirtFs::searchByRootInternal("test", dirSeparator) == nullptr);
+ REQUIRE(VirtFs::searchByRootInternal("test", std::string()) == nullptr);
VirtFs::deinit();
}
@@ -59,15 +59,15 @@ TEST_CASE("VirtFs1 mountDir")
{
REQUIRE(VirtFs::mountDirSilentTest("dir1",
Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -77,15 +77,15 @@ TEST_CASE("VirtFs1 mountDir")
{
REQUIRE(VirtFs::mountDirSilentTest("dir1/",
Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1" + sep);
@@ -97,21 +97,21 @@ TEST_CASE("VirtFs1 mountDir")
Append_false));
REQUIRE(VirtFs::mountDirSilentTest("dir2",
Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir2" + sep);
REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir2");
REQUIRE(static_cast<VirtFs::DirEntry*>(
@@ -124,19 +124,19 @@ TEST_CASE("VirtFs1 mountDir")
Append_true));
REQUIRE(VirtFs::mountDirSilentTest("dir2",
Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1" + sep);
REQUIRE(static_cast<VirtFs::DirEntry*>(
@@ -151,13 +151,13 @@ TEST_CASE("VirtFs1 mountDir")
Append_true));
REQUIRE(VirtFs::mountDirSilentTest("dir3/test",
Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir2" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep, dirSeparator) != nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ "dir3" + sep + "test" + sep, std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
@@ -166,9 +166,9 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[2]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[2]->subDir == std::string());
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
REQUIRE(static_cast<VirtFs::DirEntry*>(
@@ -186,13 +186,13 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::mountDirSilentTest("dir3\\test",
Append_false));
REQUIRE(VirtFs::searchByRootInternal(
- "dir1" + sep + "", dirSeparator) != nullptr);
+ "dir1" + sep + "", std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- "dir2" + sep + "", dirSeparator) != nullptr);
+ "dir2" + sep + "", std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- "dir3" + sep + "test" + sep, dirSeparator) != nullptr);
+ "dir3" + sep + "test" + sep, std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- "test" + sep + "", dirSeparator) == nullptr);
+ "test" + sep + "", std::string()) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep + "test" + sep);
REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
@@ -200,9 +200,9 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
- REQUIRE(VirtFs::getEntries()[2]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[2]->subDir == std::string());
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test");
REQUIRE(static_cast<VirtFs::DirEntry*>(
@@ -216,13 +216,13 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::mountDirSilentTest2("dir1",
dirSeparator,
Append_false));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, dirSeparator) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
- REQUIRE(VirtFs::searchByRootInternal("test" + sep, dirSeparator) ==
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -407,7 +407,7 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::mountDirSilentTest2("dir1",
"dir2",
Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, sep) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
nullptr);
@@ -415,7 +415,7 @@ TEST_CASE("VirtFs1 mountDir")
nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
@@ -441,7 +441,7 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::mountDirSilentTest2("dir1",
"dir2",
Append_true));
- REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, sep) !=
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir2" + sep) !=
nullptr);
@@ -449,7 +449,7 @@ TEST_CASE("VirtFs1 mountDir")
nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[1]->subDir == "dir2" + sep);
@@ -462,7 +462,26 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::unmountDirSilent2("dir1", "dir2"));
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == dirSeparator);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
+ VirtFs::getEntries()[0])->userDir == "dir1");
+ }
+
+ SECTION("subDir 9")
+ {
+ REQUIRE(VirtFs::mountDirSilentTest2("dir1",
+ dirSeparator,
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, std::string()) !=
+ nullptr);
+ REQUIRE(VirtFs::searchByRootInternal("dir1" + sep, "dir1") ==
+ nullptr);
+ REQUIRE(VirtFs::searchByRootInternal("test" + sep, std::string()) ==
+ nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 1);
+ REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -487,15 +506,15 @@ TEST_CASE("VirtFs1 mountZip")
REQUIRE(VirtFs::mountZip(prefix + "data/test/test.zip",
Append_false));
REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", dirSeparator) !=
+ prefix + "data" + sep + "test" + sep + "test.zip", std::string()) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip", dirSeparator) ==
+ prefix + "data" + sep + "test" + sep + "test2.zip", std::string()) ==
nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
}
@@ -506,20 +525,20 @@ TEST_CASE("VirtFs1 mountZip")
REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
Append_false));
REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test.zip", dirSeparator) !=
- nullptr);
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
}
SECTION("simple 3")
@@ -530,19 +549,19 @@ TEST_CASE("VirtFs1 mountZip")
Append_true));
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
}
SECTION("simple 4")
@@ -555,26 +574,26 @@ TEST_CASE("VirtFs1 mountZip")
Append_false));
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep + "");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[2]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[2]->subDir == std::string());
}
SECTION("simple 5")
@@ -587,26 +606,26 @@ TEST_CASE("VirtFs1 mountZip")
Append_true));
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "");
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[2]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
- REQUIRE(VirtFs::getEntries()[2]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[2]->subDir == std::string());
}
SECTION("subDir 1")
@@ -618,8 +637,8 @@ TEST_CASE("VirtFs1 mountZip")
prefix + "data" + sep + "test" + sep + "test.zip", "dir1" + sep) !=
nullptr);
REQUIRE(VirtFs::searchByRootInternal(
- prefix + "data" + sep + "test" + sep + "test2.zip", dirSeparator) ==
- nullptr);
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) == nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
@@ -747,6 +766,24 @@ TEST_CASE("VirtFs1 mountZip")
REQUIRE(VirtFs::getEntries()[2]->subDir == "dir3" + sep);
}
+ SECTION("subDir 6")
+ {
+ REQUIRE(VirtFs::mountZip2(prefix + "data/test/test.zip",
+ dirSeparator,
+ Append_false));
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test.zip",
+ std::string()) != nullptr);
+ REQUIRE(VirtFs::searchByRootInternal(
+ prefix + "data" + sep + "test" + sep + "test2.zip",
+ std::string()) == nullptr);
+ REQUIRE(VirtFs::getEntries().size() == 1);
+ REQUIRE(VirtFs::getEntries()[0]->root ==
+ prefix + "data" + sep + "test" + sep + "test.zip");
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
+ REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
+ }
+
VirtFs::deinit();
delete2(logger);
}
@@ -788,24 +825,24 @@ TEST_CASE("VirtFs1 unmount")
REQUIRE(VirtFs::unmountDir("dir1"));
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
REQUIRE_THROWS(VirtFs::unmountDir("dir1"));
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
@@ -813,7 +850,7 @@ TEST_CASE("VirtFs1 unmount")
REQUIRE_THROWS(VirtFs::unmountDir("dir2/dir3" + sep));
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
@@ -825,7 +862,7 @@ TEST_CASE("VirtFs1 unmount")
Append_true));
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -836,7 +873,7 @@ TEST_CASE("VirtFs1 unmount")
Append_true));
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
@@ -848,34 +885,33 @@ TEST_CASE("VirtFs1 unmount")
Append_true));
REQUIRE(VirtFs::mountZip(prefix + "data/test/test2.zip",
Append_true));
-
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Zip);
VirtFs::unmountZip(prefix + "data/test/test.zip");
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) == nullptr);
+ std::string()) == nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
}
@@ -890,45 +926,45 @@ TEST_CASE("VirtFs1 unmount")
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 3);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[2]->root ==
prefix + "data" + sep + "test" + sep + "test.zip");
- REQUIRE(VirtFs::getEntries()[2]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[2]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[2]->type == FsEntryType::Zip);
VirtFs::unmountZip(prefix + "data/test/test.zip");
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) == nullptr);
+ std::string()) == nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "",
- dirSeparator) != nullptr);
+ std::string()) != nullptr);
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root ==
prefix + "data" + sep + "test" + sep + "test2.zip");
- REQUIRE(VirtFs::getEntries()[0]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[0]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Zip);
REQUIRE(VirtFs::getEntries()[1]->root ==
prefix + "data" + sep + "test" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
}
@@ -969,7 +1005,7 @@ TEST_CASE("VirtFs1 unmount")
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
@@ -981,7 +1017,7 @@ TEST_CASE("VirtFs1 unmount")
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
- REQUIRE(VirtFs::getEntries()[1]->subDir == sep);
+ REQUIRE(VirtFs::getEntries()[1]->subDir == std::string());
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
@@ -1050,7 +1086,7 @@ TEST_CASE("VirtFs1 unmount")
"dir1");
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test.zip",
- dirSeparator) == nullptr);
+ std::string()) == nullptr);
REQUIRE(VirtFs::searchByRootInternal(
prefix + "data" + sep + "test" + sep + "test2.zip",
"dir2" + sep) != nullptr);