summaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/virtfs/fsdir.cpp4
-rw-r--r--src/fs/virtfs/fsdir.h2
-rw-r--r--src/fs/virtfs/fsfuncs.h2
-rw-r--r--src/fs/virtfs/fszip.cpp5
-rw-r--r--src/fs/virtfs/fszip.h2
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc100
6 files changed, 109 insertions, 6 deletions
diff --git a/src/fs/virtfs/fsdir.cpp b/src/fs/virtfs/fsdir.cpp
index 39c26b1b0..7556a395c 100644
--- a/src/fs/virtfs/fsdir.cpp
+++ b/src/fs/virtfs/fsdir.cpp
@@ -189,10 +189,10 @@ namespace FsDir
}
void enumerate(FsEntry *restrict const entry,
- const std::string &dirName,
+ std::string dirName,
StringVect &names)
{
- const std::string path = entry->root + dirName;
+ const std::string path = entry->root + entry->subDir + dirName;
const struct dirent *next_file = nullptr;
DIR *const dir = opendir(path.c_str());
if (dir)
diff --git a/src/fs/virtfs/fsdir.h b/src/fs/virtfs/fsdir.h
index ca3ecf1a4..01c225f95 100644
--- a/src/fs/virtfs/fsdir.h
+++ b/src/fs/virtfs/fsdir.h
@@ -56,7 +56,7 @@ namespace FsDir
std::string fileName,
std::string dirName);
void enumerate(FsEntry *restrict const entry,
- const std::string &dirName,
+ std::string dirName,
StringVect &names);
void getFiles(FsEntry *restrict const entry,
const std::string &dirName,
diff --git a/src/fs/virtfs/fsfuncs.h b/src/fs/virtfs/fsfuncs.h
index 36df93934..6b5647bcd 100644
--- a/src/fs/virtfs/fsfuncs.h
+++ b/src/fs/virtfs/fsfuncs.h
@@ -89,7 +89,7 @@ struct FsFuncs final
std::string dirName,
std::string &realDir);
void (*enumerate) (FsEntry *restrict const entry,
- const std::string &dirName,
+ std::string dirName,
StringVect &names);
void (*getFiles) (FsEntry *restrict const entry,
const std::string &dirName,
diff --git a/src/fs/virtfs/fszip.cpp b/src/fs/virtfs/fszip.cpp
index 30f3fbd8e..5118ec93c 100644
--- a/src/fs/virtfs/fszip.cpp
+++ b/src/fs/virtfs/fszip.cpp
@@ -152,10 +152,13 @@ namespace FsZip
}
void enumerate(FsEntry *restrict const entry,
- const std::string &dirName,
+ std::string dirName,
StringVect &names)
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(entry);
+ std::string subDir = zipEntry->subDir;
+ if (subDir != dirSeparator)
+ dirName = pathJoin(subDir, dirName);
if (dirName == dirSeparator)
{
FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
diff --git a/src/fs/virtfs/fszip.h b/src/fs/virtfs/fszip.h
index 2749ec60f..0abe07807 100644
--- a/src/fs/virtfs/fszip.h
+++ b/src/fs/virtfs/fszip.h
@@ -43,7 +43,7 @@ namespace FsZip
std::string filename,
std::string dirName);
void enumerate(FsEntry *restrict const entry,
- const std::string &dirName,
+ std::string dirName,
StringVect &names);
void getFiles(FsEntry *restrict const entry,
const std::string &dirName,
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index 264f92079..57d82e9af 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -1754,6 +1754,106 @@ TEST_CASE("VirtFsZip enumerateFiles9")
delete2(logger);
}
+TEST_CASE("VirtFsZip enumerateFiles10")
+{
+ VirtFs::init(".");
+ logger = new Logger;
+ std::string name("data/test/test.zip");
+ std::string prefix("data\\test/");
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountZip2(prefix + "test.zip",
+ "dir",
+ Append_false);
+
+ VirtFs::List *list = nullptr;
+
+ list = VirtFs::enumerateFiles("/");
+ REQUIRE(list->names.size() == 2);
+ REQUIRE(inList(list, "brimmedhat.png"));
+ REQUIRE(inList(list, "hide.png"));
+ VirtFs::freeList(list);
+
+ VirtFs::unmountZip2(prefix + "test.zip",
+ "dir");
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+TEST_CASE("VirtFsZip enumerateFiles11")
+{
+ VirtFs::init(".");
+ logger = new Logger;
+ std::string name("data/test/test.zip");
+ std::string prefix("data\\test/");
+ if (Files::existsLocal(name) == false)
+ prefix = "../" + prefix;
+
+ VirtFs::mountZip2(prefix + "test2.zip",
+ "dir",
+ Append_false);
+
+ VirtFs::List *list = nullptr;
+
+ list = VirtFs::enumerateFiles("1");
+ REQUIRE(list->names.size() == 2);
+ REQUIRE(inList(list, "file1.txt"));
+ REQUIRE(inList(list, "test.txt"));
+ VirtFs::freeList(list);
+
+ VirtFs::unmountZip2(prefix + "test2.zip",
+ "dir");
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+TEST_CASE("VirtFs1 enumerateFiles12")
+{
+ VirtFs::init(".");
+ logger = new Logger;
+
+ VirtFs::mountDirSilent2("data/test",
+ "dir2",
+ Append_false);
+ VirtFs::mountDirSilent2("../data/test",
+ "dir2",
+ Append_false);
+
+ VirtFs::List *list = nullptr;
+
+ list = VirtFs::enumerateFiles("/");
+ REQUIRE(inList(list, "file1.txt"));
+ REQUIRE(inList(list, "file2.txt"));
+ VirtFs::freeList(list);
+
+ VirtFs::deinit();
+ delete2(logger);
+}
+
+TEST_CASE("VirtFs1 enumerateFiles13")
+{
+ VirtFs::init(".");
+ logger = new Logger;
+
+ VirtFs::mountDirSilent2("data",
+ "test",
+ Append_false);
+ VirtFs::mountDirSilent2("../data",
+ "test",
+ Append_false);
+
+ VirtFs::List *list = nullptr;
+
+ list = VirtFs::enumerateFiles("dir2");
+ REQUIRE(inList(list, "file1.txt"));
+ REQUIRE(inList(list, "file2.txt"));
+ VirtFs::freeList(list);
+
+ VirtFs::deinit();
+ delete2(logger);
+}
+
TEST_CASE("VirtFs1 isDirectory1")
{