diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-05-16 17:32:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-05-16 17:32:31 +0300 |
commit | 5f66478632d388bfae78cbbb938a42eac3956db2 (patch) | |
tree | 106a737e821a8d3c79bf0ae172c66c18305cf990 /src/fs/virtfs/virtfs1_unittest.cc | |
parent | 0a849f982988cbd7c7afdedccb210bada702238b (diff) | |
download | manaverse-5f66478632d388bfae78cbbb938a42eac3956db2.tar.gz manaverse-5f66478632d388bfae78cbbb938a42eac3956db2.tar.bz2 manaverse-5f66478632d388bfae78cbbb938a42eac3956db2.tar.xz manaverse-5f66478632d388bfae78cbbb938a42eac3956db2.zip |
Add subdir support in VirtFs::openRead.
Diffstat (limited to 'src/fs/virtfs/virtfs1_unittest.cc')
-rw-r--r-- | src/fs/virtfs/virtfs1_unittest.cc | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc index ae3c00118..78787f9d0 100644 --- a/src/fs/virtfs/virtfs1_unittest.cc +++ b/src/fs/virtfs/virtfs1_unittest.cc @@ -2216,6 +2216,165 @@ TEST_CASE("VirtFs1 openRead2") delete2(logger); } +TEST_CASE("VirtFs1 openRead3") +{ + VirtFs::init("."); + logger = new Logger(); + std::string name("data/test/test.zip"); + std::string prefix; + if (Files::existsLocal(name) == false) + prefix = "../" + prefix; + + VirtFs::mountDir2(prefix + "data", + "test", + Append_false); + + VirtFs::File *file = nullptr; + + file = VirtFs::openRead("units.xml"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("test/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("units123.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("file1.txt"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("file2.txt"); + REQUIRE(file == nullptr); + + VirtFs::mountDir2(prefix + "data/test", + "dir2", + Append_false); + + file = VirtFs::openRead("units.xml"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("test/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("units123.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("file1.txt"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("file2.txt"); + REQUIRE(file != nullptr); + VirtFs::close(file); + + VirtFs::unmountDir2(prefix + "data/test", + "dir2"); + + file = VirtFs::openRead("units.xml"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("test/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("units123.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("file1.txt"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("file2.txt"); + REQUIRE(file == nullptr); + + VirtFs::unmountDir2(prefix + "data", + "test"); + VirtFs::deinit(); + delete2(logger); +} + +TEST_CASE("VirtFs1 openRead4") +{ + 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::File *file = nullptr; + + file = VirtFs::openRead("dye.png"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("1\\test.txt"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("dir/dye.png"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("dye.png1"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("brimmedhat.png"); + REQUIRE(file == nullptr); + + VirtFs::mountZip2(prefix + "test.zip", + "dir", + Append_false); + + file = VirtFs::openRead("dye.png"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("1\\test.txt"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("dir/dye.png"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("dye.png1"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("brimmedhat.png"); + REQUIRE(file != nullptr); + VirtFs::close(file); + + VirtFs::unmountZip2(prefix + "test.zip", + "dir"); + + file = VirtFs::openRead("dye.png"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("1\\test.txt"); + REQUIRE(file != nullptr); + VirtFs::close(file); + file = VirtFs::openRead("dir/dye.png"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("tesQ/units.xml"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("dye.png1"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("testQ"); + REQUIRE(file == nullptr); + file = VirtFs::openRead("brimmedhat.png"); + REQUIRE(file == nullptr); + + VirtFs::unmountZip2(prefix + "test2.zip", + "dir"); + + VirtFs::deinit(); + delete2(logger); +} + TEST_CASE("VirtFs1 permitLinks") { VirtFs::init("."); |