summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-05-15 20:40:58 +0300
committerAndrei Karas <akaras@inbox.ru>2017-05-15 20:40:58 +0300
commitf024212615f581d5d6df033d0d5e7d1c474fbcea (patch)
tree28dc79a193a6352a86aefdab2ce570f87ffb1ae3 /src
parent3d4ec0e043e9a683257757d3e84bec6798ff210d (diff)
downloadplus-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.gz
plus-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.bz2
plus-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.xz
plus-f024212615f581d5d6df033d0d5e7d1c474fbcea.zip
Add subdir parameter into mountZip functions.
Diffstat (limited to 'src')
-rw-r--r--src/fs/virtfs/fs.cpp72
-rw-r--r--src/fs/virtfs/fs.h5
2 files changed, 76 insertions, 1 deletions
diff --git a/src/fs/virtfs/fs.cpp b/src/fs/virtfs/fs.cpp
index 73cc04c02..61251bb35 100644
--- a/src/fs/virtfs/fs.cpp
+++ b/src/fs/virtfs/fs.cpp
@@ -579,6 +579,44 @@ namespace VirtFs
return true;
}
+ bool mountZip2(std::string newDir,
+ std::string subDir,
+ const Append append)
+ {
+ prepareFsPath(newDir);
+ if (Files::existsLocal(newDir) == false)
+ {
+ reportNonTests("FsZip::mount file not exists: %s",
+ newDir.c_str());
+ return false;
+ }
+ if (findLast(newDir, ".zip") == false)
+ {
+ reportAlways("Called VirtFs::mount without "
+ "zip archive");
+ return false;
+ }
+ prepareFsPath(subDir);
+ if (searchByRootInternal(newDir, subDir) != nullptr)
+ {
+ reportAlways("FsZip::mount already exists: %s",
+ newDir.c_str());
+ return false;
+ }
+ ZipEntry *const entry = new ZipEntry(newDir,
+ subDir,
+ FsZip::getFuncs());
+ if (ZipReader::readArchiveInfo(entry) == false)
+ {
+ delete entry;
+ return false;
+ }
+
+ logger->log("Add virtual zip: " + newDir);
+ addEntry(entry, append);
+ return true;
+ }
+
bool unmountZip(std::string oldDir)
{
prepareFsPath(oldDir);
@@ -591,7 +629,39 @@ namespace VirtFs
{
FsEntry *const entry = *it;
if (entry->root == oldDir &&
- entry->type == FsEntryType::Zip)
+ entry->type == FsEntryType::Zip &&
+ entry->subDir == dirSeparator)
+ {
+ ZipEntry *const zipEntry = static_cast<ZipEntry*>(
+ entry);
+ logger->log("Remove virtual zip: " + oldDir);
+ mEntries.erase(it);
+ delete zipEntry;
+ return true;
+ }
+ }
+
+ reportAlways("VirtFs::unmountZip not exists: %s",
+ oldDir.c_str());
+ return false;
+ }
+
+ bool unmountZip2(std::string oldDir,
+ std::string subDir)
+ {
+ prepareFsPath(oldDir);
+ if (findLast(oldDir, ".zip") == false)
+ {
+ reportAlways("Called unmount without zip archive");
+ return false;
+ }
+ prepareFsPath(subDir);
+ FOR_EACH (std::vector<FsEntry*>::iterator, it, mEntries)
+ {
+ FsEntry *const entry = *it;
+ if (entry->root == oldDir &&
+ entry->type == FsEntryType::Zip &&
+ entry->subDir == subDir)
{
ZipEntry *const zipEntry = static_cast<ZipEntry*>(
entry);
diff --git a/src/fs/virtfs/fs.h b/src/fs/virtfs/fs.h
index f8950723d..ccd5dcfdc 100644
--- a/src/fs/virtfs/fs.h
+++ b/src/fs/virtfs/fs.h
@@ -67,7 +67,12 @@ namespace VirtFs
std::string subDir);
bool mountZip(std::string newDir,
const Append append);
+ bool mountZip2(std::string newDir,
+ std::string subDir,
+ const Append append);
bool unmountZip(std::string oldDir);
+ bool unmountZip2(std::string oldDir,
+ std::string subDir);
std::string getRealDir(std::string filename);
bool mkdir(const std::string &restrict dirName);
bool remove(const std::string &restrict filename);