summaryrefslogtreecommitdiff
path: root/src/fs/virtfs
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-05 01:02:44 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-05 01:24:38 +0300
commit7594ad94dfdf580a82fb07ddb346442160b3d91d (patch)
tree9c9d0fc0b9ea0b7b1f4c550454ed0e3b458b7e2d /src/fs/virtfs
parent78195f2492032637bfa9ce663ae7903dbf07f609 (diff)
downloadmv-7594ad94dfdf580a82fb07ddb346442160b3d91d.tar.gz
mv-7594ad94dfdf580a82fb07ddb346442160b3d91d.tar.bz2
mv-7594ad94dfdf580a82fb07ddb346442160b3d91d.tar.xz
mv-7594ad94dfdf580a82fb07ddb346442160b3d91d.zip
Add VirtFs namespace into all files in virtfs directory.
Diffstat (limited to 'src/fs/virtfs')
-rw-r--r--src/fs/virtfs/virtdirentry.cpp13
-rw-r--r--src/fs/virtfs/virtdirentry.h13
-rw-r--r--src/fs/virtfs/virtfile.cpp5
-rw-r--r--src/fs/virtfs/virtfile.h5
-rw-r--r--src/fs/virtfs/virtfs.cpp16
-rw-r--r--src/fs/virtfs/virtfs.h8
-rw-r--r--src/fs/virtfs/virtfs1_unittest.cc66
-rw-r--r--src/fs/virtfs/virtfs_unittest.cc28
-rw-r--r--src/fs/virtfs/virtfsdir.cpp9
-rw-r--r--src/fs/virtfs/virtfsdir.h5
-rw-r--r--src/fs/virtfs/virtfsdirrwops.cpp5
-rw-r--r--src/fs/virtfs/virtfsdirrwops.h5
-rw-r--r--src/fs/virtfs/virtfsentry.cpp5
-rw-r--r--src/fs/virtfs/virtfsentry.h5
-rw-r--r--src/fs/virtfs/virtfsfuncs.h8
-rw-r--r--src/fs/virtfs/virtfsrwops.cpp23
-rw-r--r--src/fs/virtfs/virtfsrwops.h3
-rw-r--r--src/fs/virtfs/virtfszip.cpp7
-rw-r--r--src/fs/virtfs/virtfszip.h5
-rw-r--r--src/fs/virtfs/virtfsziprwops.cpp5
-rw-r--r--src/fs/virtfs/virtfsziprwops.h5
-rw-r--r--src/fs/virtfs/virtlist.cpp5
-rw-r--r--src/fs/virtfs/virtlist.h5
-rw-r--r--src/fs/virtfs/virtzipentry.cpp5
-rw-r--r--src/fs/virtfs/virtzipentry.h5
-rw-r--r--src/fs/virtfs/zip.cpp5
-rw-r--r--src/fs/virtfs/zip.h5
-rw-r--r--src/fs/virtfs/zip_unittest.cc78
-rw-r--r--src/fs/virtfs/ziplocalheader.cpp5
-rw-r--r--src/fs/virtfs/ziplocalheader.h5
30 files changed, 242 insertions, 120 deletions
diff --git a/src/fs/virtfs/virtdirentry.cpp b/src/fs/virtfs/virtdirentry.cpp
index a24fb12f5..d66b8bb5a 100644
--- a/src/fs/virtfs/virtdirentry.cpp
+++ b/src/fs/virtfs/virtdirentry.cpp
@@ -22,15 +22,20 @@
#include "debug.h"
-VirtDirEntry::VirtDirEntry(const std::string &userDir0,
- const std::string &rootDir,
- VirtFsFuncs *restrict const funcs0) :
+namespace VirtFs
+{
+
+DirEntry::DirEntry(const std::string &userDir0,
+ const std::string &rootDir,
+ VirtFsFuncs *restrict const funcs0) :
VirtFsEntry(FsEntryType::Dir, funcs0),
userDir(userDir0)
{
root = rootDir;
}
-VirtDirEntry::~VirtDirEntry()
+DirEntry::~DirEntry()
{
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtdirentry.h b/src/fs/virtfs/virtdirentry.h
index 282eb21cd..fa5eabb16 100644
--- a/src/fs/virtfs/virtdirentry.h
+++ b/src/fs/virtfs/virtdirentry.h
@@ -25,17 +25,22 @@
#include "localconsts.h"
-struct VirtDirEntry final : public VirtFsEntry
+namespace VirtFs
{
- VirtDirEntry(const std::string &userDir,
+
+struct DirEntry final : public VirtFsEntry
+{
+ DirEntry(const std::string &userDir,
const std::string &rootDir,
VirtFsFuncs *restrict const funcs);
- A_DELETE_COPY(VirtDirEntry)
+ A_DELETE_COPY(DirEntry)
- ~VirtDirEntry();
+ ~DirEntry();
std::string userDir;
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTDIRENTRY_H
diff --git a/src/fs/virtfs/virtfile.cpp b/src/fs/virtfs/virtfile.cpp
index 957392bef..2888e4557 100644
--- a/src/fs/virtfs/virtfile.cpp
+++ b/src/fs/virtfs/virtfile.cpp
@@ -22,6 +22,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
VirtFile::VirtFile(const VirtFsFuncs *restrict const funcs0,
const uint8_t *restrict const buf,
const size_t sz) :
@@ -49,3 +52,5 @@ VirtFile::~VirtFile()
FILECLOSE(mFd);
delete [] mBuf;
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfile.h b/src/fs/virtfs/virtfile.h
index 7896c848f..b6cfca5c5 100644
--- a/src/fs/virtfs/virtfile.h
+++ b/src/fs/virtfs/virtfile.h
@@ -25,6 +25,9 @@
#include "fs/virtfs/fileapi.h"
+namespace VirtFs
+{
+
struct VirtFsFuncs;
struct VirtFile final
@@ -53,4 +56,6 @@ struct VirtFile final
FILEHTYPE mFd;
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTFILE_H
diff --git a/src/fs/virtfs/virtfs.cpp b/src/fs/virtfs/virtfs.cpp
index 732bd0ed3..301068233 100644
--- a/src/fs/virtfs/virtfs.cpp
+++ b/src/fs/virtfs/virtfs.cpp
@@ -39,11 +39,6 @@
const char *dirSeparator = nullptr;
-namespace
-{
- std::vector<VirtFsEntry*> mEntries;
-} // namespace
-
#ifdef UNITTESTS
#define reportNonTests logger->log
#else // UNITTESTS
@@ -52,6 +47,11 @@ namespace
namespace VirtFs
{
+ namespace
+ {
+ std::vector<VirtFsEntry*> mEntries;
+ } // namespace
+
void init(const std::string &restrict name)
{
updateDirSeparator();
@@ -353,7 +353,7 @@ namespace VirtFs
return false;
}
logger->log("Add virtual directory: " + newDir);
- addEntry(new VirtDirEntry(newDir, rootDir, VirtFsDir::getFuncs()),
+ addEntry(new DirEntry(newDir, rootDir, VirtFsDir::getFuncs()),
append);
return true;
}
@@ -408,7 +408,7 @@ namespace VirtFs
if (entry->root == oldDir &&
entry->type == FsEntryType::Dir)
{
- VirtDirEntry *const dirEntry = static_cast<VirtDirEntry*>(
+ DirEntry *const dirEntry = static_cast<DirEntry*>(
entry);
logger->log("Remove virtual directory: " + oldDir);
mEntries.erase(it);
@@ -563,7 +563,7 @@ namespace VirtFs
{
VirtFsEntry *const entry = *it;
if (entry->type == FsEntryType::Dir)
- delete static_cast<VirtDirEntry*>(entry);
+ delete static_cast<DirEntry*>(entry);
else if (entry->type == FsEntryType::Zip)
delete static_cast<VirtZipEntry*>(entry);
else
diff --git a/src/fs/virtfs/virtfs.h b/src/fs/virtfs/virtfs.h
index 2d95b55c9..b526a5f08 100644
--- a/src/fs/virtfs/virtfs.h
+++ b/src/fs/virtfs/virtfs.h
@@ -29,12 +29,12 @@
#include "localconsts.h"
-struct VirtFile;
-struct VirtFsEntry;
-struct VirtList;
-
namespace VirtFs
{
+ struct VirtFile;
+ struct VirtFsEntry;
+ struct VirtList;
+
void init(const std::string &restrict name);
void updateDirSeparator();
const char *getDirSeparator();
diff --git a/src/fs/virtfs/virtfs1_unittest.cc b/src/fs/virtfs/virtfs1_unittest.cc
index 0c7f1c84b..d22336f44 100644
--- a/src/fs/virtfs/virtfs1_unittest.cc
+++ b/src/fs/virtfs/virtfs1_unittest.cc
@@ -64,7 +64,7 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
}
@@ -77,7 +77,7 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1" + sep);
}
@@ -95,9 +95,9 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries()[1]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir2");
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir1");
}
@@ -115,9 +115,9 @@ TEST_CASE("VirtFs1 mountDir")
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
REQUIRE(VirtFs::getEntries()[1]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1" + sep);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2");
}
@@ -141,11 +141,11 @@ 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(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2");
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[2])->userDir == "dir3" + sep + "test");
}
@@ -172,11 +172,11 @@ 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(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3" + sep + "test");
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir1");
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[2])->userDir == "dir2");
}
@@ -340,28 +340,28 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE(VirtFs::getEntries().size() == 2);
REQUIRE(VirtFs::getEntries()[0]->root == "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ 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]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
REQUIRE(VirtFs::getEntries()[1]->root == "dir2" + sep + "dir3" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[1])->userDir == "dir2" + sep + "dir3");
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);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir3");
}
@@ -372,7 +372,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
REQUIRE_THROWS(VirtFs::unmountDir("dir2"));
REQUIRE(VirtFs::unmountDir("dir1"));
@@ -382,7 +382,7 @@ TEST_CASE("VirtFs1 removeFromSearchPath")
REQUIRE(VirtFs::getEntries().size() == 1);
REQUIRE(VirtFs::getEntries()[0]->root == "dir1" + sep);
REQUIRE(VirtFs::getEntries()[0]->type == FsEntryType::Dir);
- REQUIRE(static_cast<VirtDirEntry*>(
+ REQUIRE(static_cast<VirtFs::DirEntry*>(
VirtFs::getEntries()[0])->userDir == "dir1");
}
@@ -673,7 +673,7 @@ TEST_CASE("VirtFs1 getRealDir2")
delete2(logger);
}
-static bool inList(const VirtList *const list,
+static bool inList(const VirtFs::VirtList *const list,
const std::string &name)
{
FOR_EACH (StringVectCIter, it, list->names)
@@ -718,7 +718,7 @@ TEST_CASE("VirtFs1 enumerateFiles1")
VirtFs::mountDirSilent("../data",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
const int cnt1 = VirtFs::exists("test/test2.txt") ? 28 : 27;
const int cnt2 = 28;
@@ -763,7 +763,7 @@ TEST_CASE("VirtFs1 enumerateFiles2")
VirtFs::mountDirSilent("../data/test/dir1",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 5);
@@ -788,7 +788,7 @@ TEST_CASE("VirtFs1 enumerateFiles3")
VirtFs::mountDirSilent("../data/test/dir2",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
const size_t sz = list->names.size();
@@ -811,7 +811,7 @@ TEST_CASE("VirtFsZip enumerateFiles4")
VirtFs::mountZip(prefix + "test.zip",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("dir");
REQUIRE(list->names.size() == 2);
@@ -838,7 +838,7 @@ TEST_CASE("VirtFsZip enumerateFiles5")
VirtFs::mountZip(prefix + "test2.zip",
Append_true);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("dir");
FOR_EACH (StringVectCIter, it, list->names)
@@ -872,7 +872,7 @@ TEST_CASE("VirtFsZip enumerateFiles6")
VirtFs::mountZip(prefix + "test.zip",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 1);
@@ -896,7 +896,7 @@ TEST_CASE("VirtFsZip enumerateFiles7")
VirtFs::mountZip(prefix + "test2.zip",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 4);
@@ -925,7 +925,7 @@ TEST_CASE("VirtFsZip enumerateFiles8")
VirtFs::mountDirSilent(prefix + "data/test",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("dir2");
REQUIRE(list->names.size() >= 6);
@@ -957,7 +957,7 @@ TEST_CASE("VirtFsZip enumerateFiles9")
VirtFs::mountDirSilent(prefix + "data/test",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("dir");
REQUIRE(list->names.size() == 4);
@@ -1135,7 +1135,7 @@ TEST_CASE("VirtFs1 openRead1")
VirtFs::mountDir(prefix + "data",
Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
file = VirtFs::openRead("test/units.xml");
REQUIRE(file != nullptr);
@@ -1199,7 +1199,7 @@ TEST_CASE("VirtFs1 openRead2")
VirtFs::mountZip(prefix + "test2.zip",
Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
file = VirtFs::openRead("dir2/units.xml");
REQUIRE(file != nullptr);
@@ -1317,7 +1317,7 @@ TEST_CASE("VirtFs1 read1")
VirtFs::mountDir(prefix + "data",
Append_false);
- VirtFile *file = VirtFs::openRead("test/test.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("test/test.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
@@ -1358,7 +1358,7 @@ TEST_CASE("VirtFs1 read2")
VirtFs::mountZip(prefix + "test2.zip",
Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
void *restrict buffer = nullptr;
SECTION("test 1")
diff --git a/src/fs/virtfs/virtfs_unittest.cc b/src/fs/virtfs/virtfs_unittest.cc
index cd984213f..cb9a7d4ad 100644
--- a/src/fs/virtfs/virtfs_unittest.cc
+++ b/src/fs/virtfs/virtfs_unittest.cc
@@ -216,7 +216,7 @@ static void removeTemp(StringVect &restrict list)
}
}
-static bool inList(const VirtList *const list,
+static bool inList(const VirtFs::VirtList *const list,
const std::string &name)
{
FOR_EACH (StringVectCIter, it, list->names)
@@ -234,7 +234,7 @@ TEST_CASE("VirtFs enumerateFiles1")
VirtFs::mountDirSilent("data", Append_false);
VirtFs::mountDirSilent("../data", Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
const int cnt1 = VirtFs::exists("test/test2.txt") ? 28 : 27;
const int cnt2 = 28;
@@ -277,7 +277,7 @@ TEST_CASE("VirtFs enumerateFiles2")
VirtFs::mountDirSilent("../data/test/dir1",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 5);
@@ -299,7 +299,7 @@ TEST_CASE("VirtFs enumerateFiles3")
VirtFs::mountZip(prefix + "data/test/test.zip",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 1);
@@ -321,7 +321,7 @@ TEST_CASE("VirtFs enumerateFiles4")
VirtFs::mountZip(prefix + "data/test/test2.zip",
Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("/");
REQUIRE(list->names.size() == 4);
@@ -347,7 +347,7 @@ TEST_CASE("VirtFs enumerateFiles5")
Append_false);
VirtFs::mountDirSilent(prefix + "data/test", Append_false);
- VirtList *list = nullptr;
+ VirtFs::VirtList *list = nullptr;
list = VirtFs::enumerateFiles("dir2");
REQUIRE(inList(list, "file1.txt"));
@@ -476,7 +476,7 @@ TEST_CASE("VirtFs openRead1")
VirtFs::mountDirSilent("data", Append_false);
VirtFs::mountDirSilent("../data", Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
file = VirtFs::openRead("test/units.xml");
REQUIRE(file != nullptr);
@@ -542,7 +542,7 @@ TEST_CASE("VirtFs openRead2")
VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
file = VirtFs::openRead("test/units.xml");
REQUIRE(file == nullptr);
@@ -571,7 +571,7 @@ TEST_CASE("VirtFs openRead3")
VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
VirtFs::mountDir(prefix + "data/test", Append_false);
- VirtFile *file = nullptr;
+ VirtFs::VirtFile *file = nullptr;
file = VirtFs::openRead("test/units.xml");
REQUIRE(file == nullptr);
@@ -755,7 +755,7 @@ TEST_CASE("VirtFs read1")
VirtFs::mountDirSilent("data", Append_false);
VirtFs::mountDirSilent("../data", Append_false);
- VirtFile *file = VirtFs::openRead("test/test.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("test/test.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
@@ -795,7 +795,7 @@ TEST_CASE("VirtFs read2")
VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
- VirtFile *file = VirtFs::openRead("dir2/test.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("dir2/test.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
@@ -835,7 +835,7 @@ TEST_CASE("VirtFs read3")
VirtFs::mountZip(prefix + "data/test/test2.zip", Append_false);
VirtFs::mountDir(prefix + "data", Append_false);
- VirtFile *file = VirtFs::openRead("dir2/test.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("dir2/test.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
@@ -876,7 +876,7 @@ TEST_CASE("VirtFs read4")
VirtFs::mountDir(prefix + "data/test", Append_true);
VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true);
- VirtFile *file = VirtFs::openRead("dir1/file1.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("dir1/file1.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
@@ -917,7 +917,7 @@ TEST_CASE("VirtFs read5")
VirtFs::mountZip(prefix + "data/test/test5.zip", Append_true);
VirtFs::mountDir(prefix + "data/test", Append_true);
- VirtFile *file = VirtFs::openRead("dir1/file1.txt");
+ VirtFs::VirtFile *file = VirtFs::openRead("dir1/file1.txt");
REQUIRE(file != nullptr);
REQUIRE(VirtFs::fileLength(file) == 23);
const int fileSize = VirtFs::fileLength(file);
diff --git a/src/fs/virtfs/virtfsdir.cpp b/src/fs/virtfs/virtfsdir.cpp
index 902e686c0..fce38b023 100644
--- a/src/fs/virtfs/virtfsdir.cpp
+++ b/src/fs/virtfs/virtfsdir.cpp
@@ -47,6 +47,9 @@
extern const char *dirSeparator;
+namespace VirtFs
+{
+
namespace
{
std::string mWriteDir;
@@ -169,7 +172,7 @@ namespace VirtFsDir
const std::string &dirName A_UNUSED,
std::string &realDir)
{
- VirtDirEntry *const dirEntry = static_cast<VirtDirEntry*>(entry);
+ DirEntry *const dirEntry = static_cast<DirEntry*>(entry);
if (Files::existsLocal(dirEntry->root + filename))
{
realDir = dirEntry->userDir;
@@ -458,7 +461,7 @@ namespace VirtFsDir
const std::string &restrict filename,
int &restrict fileSize)
{
- const VirtDirEntry *const dirEntry = static_cast<VirtDirEntry*>(entry);
+ const DirEntry *const dirEntry = static_cast<DirEntry*>(entry);
const std::string path = entry->root + filename;
if (Files::existsLocal(path) == false)
return nullptr;
@@ -663,4 +666,6 @@ namespace VirtFsDir
closedir(dir);
}
}
+} // namespace VirtFsDir
+
} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfsdir.h b/src/fs/virtfs/virtfsdir.h
index 12a4ee831..ec525d719 100644
--- a/src/fs/virtfs/virtfsdir.h
+++ b/src/fs/virtfs/virtfsdir.h
@@ -27,6 +27,9 @@
#include "localconsts.h"
+namespace VirtFs
+{
+
struct VirtFile;
struct VirtFsEntry;
struct VirtFsFuncs;
@@ -96,4 +99,6 @@ namespace VirtFsDir
int &restrict fileSize);
} // namespace VirtFsDir
+} // namespace VirtFs
+
#endif // UTILS_VIRTFSDIR_H
diff --git a/src/fs/virtfs/virtfsdirrwops.cpp b/src/fs/virtfs/virtfsdirrwops.cpp
index 64ad474e2..14cc69db8 100644
--- a/src/fs/virtfs/virtfsdirrwops.cpp
+++ b/src/fs/virtfs/virtfsdirrwops.cpp
@@ -28,6 +28,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
namespace VirtFsDir
{
RWOPSINT rwops_seek(SDL_RWops *const rw,
@@ -249,3 +252,5 @@ namespace VirtFsDir
#endif // USE_SDL2
} // namespace VirtFsDir
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfsdirrwops.h b/src/fs/virtfs/virtfsdirrwops.h
index 6751694d1..4369c5eb1 100644
--- a/src/fs/virtfs/virtfsdirrwops.h
+++ b/src/fs/virtfs/virtfsdirrwops.h
@@ -27,6 +27,9 @@ struct SDL_RWops;
#include "localconsts.h"
+namespace VirtFs
+{
+
namespace VirtFsDir
{
RWOPSINT rwops_seek(SDL_RWops *const rw,
@@ -47,4 +50,6 @@ namespace VirtFsDir
} // namespace VirtFsDir
+} // namespace VirtFs
+
#endif // UTILS_VIRTFS_VIRTFSDIRRWOPS_H
diff --git a/src/fs/virtfs/virtfsentry.cpp b/src/fs/virtfs/virtfsentry.cpp
index 09f68148a..a02ab938c 100644
--- a/src/fs/virtfs/virtfsentry.cpp
+++ b/src/fs/virtfs/virtfsentry.cpp
@@ -22,6 +22,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
VirtFsEntry::VirtFsEntry(const FsEntryTypeT &type0,
VirtFsFuncs *restrict const funcs0) :
root(),
@@ -33,3 +36,5 @@ VirtFsEntry::VirtFsEntry(const FsEntryTypeT &type0,
VirtFsEntry::~VirtFsEntry()
{
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfsentry.h b/src/fs/virtfs/virtfsentry.h
index 467d374cb..8394459de 100644
--- a/src/fs/virtfs/virtfsentry.h
+++ b/src/fs/virtfs/virtfsentry.h
@@ -27,6 +27,9 @@
#include "localconsts.h"
+namespace VirtFs
+{
+
struct VirtFsFuncs;
struct VirtFsEntry notfinal
@@ -45,4 +48,6 @@ struct VirtFsEntry notfinal
VirtFsFuncs *funcs;
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTFSENTRY_H
diff --git a/src/fs/virtfs/virtfsfuncs.h b/src/fs/virtfs/virtfsfuncs.h
index eb617ebd4..e6213a6ce 100644
--- a/src/fs/virtfs/virtfsfuncs.h
+++ b/src/fs/virtfs/virtfsfuncs.h
@@ -27,9 +27,13 @@
#include "localconsts.h"
+struct SDL_RWops;
+
+namespace VirtFs
+{
+
struct VirtFile;
struct VirtFsEntry;
-struct SDL_RWops;
struct VirtFsFuncs final
{
@@ -127,4 +131,6 @@ struct VirtFsFuncs final
int (*rwops_close) (SDL_RWops *const rw);
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTFSFUNCS_H
diff --git a/src/fs/virtfs/virtfsrwops.cpp b/src/fs/virtfs/virtfsrwops.cpp
index 101ce66b6..ab13c3f4e 100644
--- a/src/fs/virtfs/virtfsrwops.cpp
+++ b/src/fs/virtfs/virtfsrwops.cpp
@@ -56,7 +56,10 @@
#include "debug.h"
-SDL_RWops *VirtFs::create_rwops(VirtFile *const file)
+namespace VirtFs
+{
+
+SDL_RWops *create_rwops(VirtFile *const file)
{
SDL_RWops *retval = nullptr;
@@ -89,13 +92,13 @@ static bool checkFilePath(const std::string &restrict fname)
{
if (fname.empty())
return false;
- if (!VirtFs::exists(fname) || VirtFs::isDirectory(fname))
+ if (!exists(fname) || isDirectory(fname))
return false;
return true;
}
#endif // __APPLE__
-SDL_RWops *VirtFs::rwopsOpenRead(const std::string &restrict fname)
+SDL_RWops *rwopsOpenRead(const std::string &restrict fname)
{
BLOCK_START("RWopsopenRead")
#ifdef __APPLE__
@@ -108,34 +111,36 @@ SDL_RWops *VirtFs::rwopsOpenRead(const std::string &restrict fname)
#endif // USE_FUZZER
#ifdef USE_PROFILER
- SDL_RWops *const ret = VirtFs::create_rwops(VirtFs::openRead(fname));
+ SDL_RWops *const ret = create_rwops(openRead(fname));
BLOCK_END("RWopsopenRead")
return ret;
#else // USE_PROFILER
- return VirtFs::create_rwops(VirtFs::openRead(fname));
+ return create_rwops(openRead(fname));
#endif // USE_PROFILER
} /* RWopsopenRead */
-SDL_RWops *VirtFs::rwopsOpenWrite(const std::string &restrict fname)
+SDL_RWops *rwopsOpenWrite(const std::string &restrict fname)
{
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
#endif // __APPLE__
- return VirtFs::create_rwops(VirtFs::openWrite(fname));
+ return create_rwops(openWrite(fname));
} /* RWopsopenWrite */
-SDL_RWops *VirtFs::rwopsOpenAppend(const std::string &restrict fname)
+SDL_RWops *rwopsOpenAppend(const std::string &restrict fname)
{
#ifdef __APPLE__
if (!checkFilePath(fname))
return nullptr;
#endif // __APPLE__
- return VirtFs::create_rwops(VirtFs::openAppend(fname));
+ return create_rwops(openAppend(fname));
} /* RWopsopenAppend */
+} // namespace VirtFs
+
/* end of virtfsrwops.c ... */
diff --git a/src/fs/virtfs/virtfsrwops.h b/src/fs/virtfs/virtfsrwops.h
index 3f0a7663f..7182a08c5 100644
--- a/src/fs/virtfs/virtfsrwops.h
+++ b/src/fs/virtfs/virtfsrwops.h
@@ -50,10 +50,11 @@
#include <string>
struct SDL_RWops;
-struct VirtFile;
namespace VirtFs
{
+ struct VirtFile;
+
SDL_RWops *create_rwops(VirtFile *const file);
SDL_RWops *rwopsOpenRead(const std::string &restrict fname);
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index 7d2f0e8b6..a3b477844 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -37,9 +37,12 @@ extern const char *dirSeparator;
namespace
{
- VirtFsFuncs funcs;
+ VirtFs::VirtFsFuncs funcs;
} // namespace
+namespace VirtFs
+{
+
namespace VirtFsZip
{
VirtFsFuncs *getFuncs()
@@ -659,3 +662,5 @@ namespace VirtFsZip
return nullptr;
}
} // namespace VirtFsZip
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfszip.h b/src/fs/virtfs/virtfszip.h
index 5ffd545f8..0dd8d1f82 100644
--- a/src/fs/virtfs/virtfszip.h
+++ b/src/fs/virtfs/virtfszip.h
@@ -25,6 +25,9 @@
#include "localconsts.h"
+namespace VirtFs
+{
+
struct VirtFile;
struct VirtList;
struct VirtFsFuncs;
@@ -85,4 +88,6 @@ namespace VirtFsZip
int &restrict fileSize);
} // namespace VirtFsZip
+} // namespace VirtFs
+
#endif // UTILS_VIRTFSZIP_H
diff --git a/src/fs/virtfs/virtfsziprwops.cpp b/src/fs/virtfs/virtfsziprwops.cpp
index 717227e46..aecd3c5f5 100644
--- a/src/fs/virtfs/virtfsziprwops.cpp
+++ b/src/fs/virtfs/virtfsziprwops.cpp
@@ -29,6 +29,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
namespace VirtFsZip
{
RWOPSINT rwops_seek(SDL_RWops *const rw,
@@ -146,3 +149,5 @@ namespace VirtFsZip
#endif // USE_SDL2
} // namespace VirtFsZip
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtfsziprwops.h b/src/fs/virtfs/virtfsziprwops.h
index 4748cc875..b2fa65319 100644
--- a/src/fs/virtfs/virtfsziprwops.h
+++ b/src/fs/virtfs/virtfsziprwops.h
@@ -27,6 +27,9 @@
struct SDL_RWops;
+namespace VirtFs
+{
+
namespace VirtFsZip
{
RWOPSINT rwops_seek(SDL_RWops *const rw,
@@ -47,4 +50,6 @@ namespace VirtFsZip
} // namespace VirtFsZip
+} // namespace VirtFs
+
#endif // UTILS_VIRTFS_VIRTFSZIPRWOPS_H
diff --git a/src/fs/virtfs/virtlist.cpp b/src/fs/virtfs/virtlist.cpp
index a2e8219f6..332968d09 100644
--- a/src/fs/virtfs/virtlist.cpp
+++ b/src/fs/virtfs/virtlist.cpp
@@ -22,6 +22,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
VirtList::VirtList() :
names()
{
@@ -30,3 +33,5 @@ VirtList::VirtList() :
VirtList::~VirtList()
{
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtlist.h b/src/fs/virtfs/virtlist.h
index 5b1d10924..7f698e6ad 100644
--- a/src/fs/virtfs/virtlist.h
+++ b/src/fs/virtfs/virtlist.h
@@ -25,6 +25,9 @@
#include "localconsts.h"
+namespace VirtFs
+{
+
struct VirtList final
{
VirtList();
@@ -36,4 +39,6 @@ struct VirtList final
StringVect names;
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTLIST_H
diff --git a/src/fs/virtfs/virtzipentry.cpp b/src/fs/virtfs/virtzipentry.cpp
index c832578bd..2cd3b30f5 100644
--- a/src/fs/virtfs/virtzipentry.cpp
+++ b/src/fs/virtfs/virtzipentry.cpp
@@ -26,6 +26,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
VirtZipEntry::VirtZipEntry(const std::string &restrict archiveName,
VirtFsFuncs *restrict const funcs0) :
VirtFsEntry(FsEntryType::Zip, funcs0),
@@ -39,3 +42,5 @@ VirtZipEntry::~VirtZipEntry()
{
delete_all(mHeaders);
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/virtzipentry.h b/src/fs/virtfs/virtzipentry.h
index d3c69aa36..e0bdf4847 100644
--- a/src/fs/virtfs/virtzipentry.h
+++ b/src/fs/virtfs/virtzipentry.h
@@ -27,6 +27,9 @@
#include "localconsts.h"
+namespace VirtFs
+{
+
struct ZipLocalHeader;
struct VirtZipEntry final : public VirtFsEntry
@@ -42,4 +45,6 @@ struct VirtZipEntry final : public VirtFsEntry
std::vector<std::string> mDirs;
};
+} // namespace VirtFs
+
#endif // UTILS_VIRTZIPENTRY_H
diff --git a/src/fs/virtfs/zip.cpp b/src/fs/virtfs/zip.cpp
index f10f8f70d..63cfb59b9 100644
--- a/src/fs/virtfs/zip.cpp
+++ b/src/fs/virtfs/zip.cpp
@@ -65,6 +65,9 @@ extern const char *dirSeparator;
#define swapVal32(val)
#endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
+namespace VirtFs
+{
+
namespace Zip
{
bool readArchiveInfo(VirtZipEntry *const entry)
@@ -319,3 +322,5 @@ namespace Zip
return out;
}
} // namespace Zip
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/zip.h b/src/fs/virtfs/zip.h
index d2d90b28e..e74ff09aa 100644
--- a/src/fs/virtfs/zip.h
+++ b/src/fs/virtfs/zip.h
@@ -25,6 +25,9 @@
#include <string>
+namespace VirtFs
+{
+
struct VirtZipEntry;
struct ZipLocalHeader;
@@ -38,4 +41,6 @@ namespace Zip
const uint8_t *readFile(const ZipLocalHeader *restrict const header);
} // namespace Zip
+} // namespace VirtFs
+
#endif // UTILS_ZIP_H
diff --git a/src/fs/virtfs/zip_unittest.cc b/src/fs/virtfs/zip_unittest.cc
index 9d471795c..ad42f6a4a 100644
--- a/src/fs/virtfs/zip_unittest.cc
+++ b/src/fs/virtfs/zip_unittest.cc
@@ -48,11 +48,11 @@ TEST_CASE("Zip readArchiveInfo")
{
name = prefix + "data/test/test.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 2);
REQUIRE(entry->root == name);
REQUIRE(headers[0]->fileName == "dir" + sep + "hide.png");
@@ -69,11 +69,11 @@ TEST_CASE("Zip readArchiveInfo")
{
name = prefix + "data/test/test2.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 11);
REQUIRE(entry->root == name);
REQUIRE(headers[0]->fileName == "test.txt");
@@ -131,11 +131,11 @@ TEST_CASE("Zip readArchiveInfo")
{
name = prefix + "data/test/test3.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 2);
REQUIRE(entry->root == name);
REQUIRE(headers[0]->fileName == "test.txt");
@@ -152,11 +152,11 @@ TEST_CASE("Zip readArchiveInfo")
{
name = prefix + "data/test/test4.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(entry->root == name);
REQUIRE(headers.size() == 0);
@@ -176,22 +176,22 @@ TEST_CASE("Zip readCompressedFile")
SECTION("empty")
{
- REQUIRE_THROWS(Zip::readCompressedFile(nullptr));
+ REQUIRE_THROWS(VirtFs::Zip::readCompressedFile(nullptr));
}
SECTION("test2.zip")
{
name = prefix + "data/test/test2.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 11);
REQUIRE(entry->root == name);
// test.txt
- uint8_t *const buf = Zip::readCompressedFile(headers[0]);
+ uint8_t *const buf = VirtFs::Zip::readCompressedFile(headers[0]);
REQUIRE(buf != nullptr);
delete [] buf;
delete entry;
@@ -210,18 +210,18 @@ TEST_CASE("Zip readFile")
SECTION("empty")
{
- REQUIRE_THROWS(Zip::readFile(nullptr));
+ REQUIRE_THROWS(VirtFs::Zip::readFile(nullptr));
}
SECTION("test.zip")
{
name = prefix + "data/test/test.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 2);
REQUIRE(entry->root == name);
for (int f = 0; f < 2; f ++)
@@ -230,7 +230,7 @@ TEST_CASE("Zip readFile")
headers[f]->fileName.c_str(),
headers[f]->compressSize,
headers[f]->uncompressSize);
- const uint8_t *const buf = Zip::readFile(headers[f]);
+ const uint8_t *const buf = VirtFs::Zip::readFile(headers[f]);
REQUIRE(buf != nullptr);
delete [] buf;
}
@@ -241,15 +241,15 @@ TEST_CASE("Zip readFile")
{
name = prefix + "data/test/test2.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 11);
REQUIRE(entry->root == name);
// test.txt
- const uint8_t *buf = Zip::readFile(headers[0]);
+ const uint8_t *buf = VirtFs::Zip::readFile(headers[0]);
REQUIRE(buf != nullptr);
const std::string str = std::string(reinterpret_cast<const char*>(buf),
headers[0]->uncompressSize);
@@ -261,7 +261,7 @@ TEST_CASE("Zip readFile")
headers[f]->fileName.c_str(),
headers[f]->compressSize,
headers[f]->uncompressSize);
- buf = Zip::readFile(headers[f]);
+ buf = VirtFs::Zip::readFile(headers[f]);
REQUIRE(buf != nullptr);
delete [] buf;
}
@@ -272,11 +272,11 @@ TEST_CASE("Zip readFile")
{
name = prefix + "data/test/test3.zip";
- VirtZipEntry *const entry = new VirtZipEntry(name,
- VirtFsZip::getFuncs());
- std::vector<ZipLocalHeader*> &headers = entry->mHeaders;
+ VirtFs::VirtZipEntry *const entry = new VirtFs::VirtZipEntry(name,
+ VirtFs::VirtFsZip::getFuncs());
+ std::vector<VirtFs::ZipLocalHeader*> &headers = entry->mHeaders;
- REQUIRE(Zip::readArchiveInfo(entry));
+ REQUIRE(VirtFs::Zip::readArchiveInfo(entry));
REQUIRE(headers.size() == 2);
REQUIRE(entry->root == name);
for (int f = 0; f < 2; f ++)
@@ -285,7 +285,7 @@ TEST_CASE("Zip readFile")
headers[f]->fileName.c_str(),
headers[f]->compressSize,
headers[f]->uncompressSize);
- const uint8_t *const buf = Zip::readFile(headers[f]);
+ const uint8_t *const buf = VirtFs::Zip::readFile(headers[f]);
REQUIRE(buf != nullptr);
delete [] buf;
}
diff --git a/src/fs/virtfs/ziplocalheader.cpp b/src/fs/virtfs/ziplocalheader.cpp
index 47ed4d290..437140d07 100644
--- a/src/fs/virtfs/ziplocalheader.cpp
+++ b/src/fs/virtfs/ziplocalheader.cpp
@@ -24,6 +24,9 @@
#include "debug.h"
+namespace VirtFs
+{
+
ZipLocalHeader::ZipLocalHeader() :
fileName(),
zipEntry(nullptr),
@@ -33,3 +36,5 @@ ZipLocalHeader::ZipLocalHeader() :
compressed(false)
{
}
+
+} // namespace VirtFs
diff --git a/src/fs/virtfs/ziplocalheader.h b/src/fs/virtfs/ziplocalheader.h
index f3a1894ce..c81d414bf 100644
--- a/src/fs/virtfs/ziplocalheader.h
+++ b/src/fs/virtfs/ziplocalheader.h
@@ -25,6 +25,9 @@
#include <string>
+namespace VirtFs
+{
+
struct VirtZipEntry;
struct ZipLocalHeader final
@@ -41,4 +44,6 @@ struct ZipLocalHeader final
bool compressed;
};
+} // namespace VirtFs
+
#endif // UTILS_ZIPLOCALHEADER_H