summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/fs.cpp
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/fs/virtfs/fs.cpp
parent3d4ec0e043e9a683257757d3e84bec6798ff210d (diff)
downloadmv-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.gz
mv-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.bz2
mv-f024212615f581d5d6df033d0d5e7d1c474fbcea.tar.xz
mv-f024212615f581d5d6df033d0d5e7d1c474fbcea.zip
Add subdir parameter into mountZip functions.
Diffstat (limited to 'src/fs/virtfs/fs.cpp')
-rw-r--r--src/fs/virtfs/fs.cpp72
1 files changed, 71 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);