summaryrefslogtreecommitdiff
path: root/src/fs/virtfs/virtfszip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/virtfs/virtfszip.cpp')
-rw-r--r--src/fs/virtfs/virtfszip.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp
index ae31f2606..bf7e8fba2 100644
--- a/src/fs/virtfs/virtfszip.cpp
+++ b/src/fs/virtfs/virtfszip.cpp
@@ -75,6 +75,7 @@ namespace VirtFsZip
ptr->openAppend = &VirtFsZip::openAppend;
ptr->loadFile = &VirtFsZip::loadFile;
ptr->getFiles = &VirtFsZip::getFiles;
+ ptr->getDirs = &VirtFsZip::getDirs;
ptr->rwops_seek = &VirtFsZip::rwops_seek;
ptr->rwops_read = &VirtFsZip::rwops_read;
ptr->rwops_write = &VirtFsZip::rwops_write;
@@ -287,6 +288,98 @@ namespace VirtFsZip
}
}
+ void getDirs(VirtFsEntry *restrict const entry,
+ const std::string &dirName,
+ StringVect &names)
+ {
+ VirtZipEntry *const zipEntry = static_cast<VirtZipEntry*>(entry);
+ if (dirName == dirSeparator)
+ {
+ FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
+ it2,
+ zipEntry->mHeaders)
+ {
+ ZipLocalHeader *const header = *it2;
+ std::string fileName = header->fileName;
+ // skip subdirs from enumeration
+ const size_t idx = fileName.find(dirSeparator);
+ if (idx != std::string::npos)
+ fileName.erase(idx);
+ bool found(false);
+ FOR_EACH (StringVectCIter, itn, names)
+ {
+ if (*itn == fileName)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ {
+ std::string dirName2 = pathJoin(dirName, fileName);
+ if (findLast(dirName2, std::string(dirSeparator)) == false)
+ dirName2 += dirSeparator;
+ FOR_EACH (std::vector<std::string>::const_iterator,
+ it,
+ zipEntry->mDirs)
+ {
+ if (*it == dirName2)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found == true)
+ names.push_back(fileName);
+ }
+ }
+ }
+ else
+ {
+ FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
+ it2,
+ zipEntry->mHeaders)
+ {
+ ZipLocalHeader *const header = *it2;
+ std::string fileName = header->fileName;
+ if (findCutFirst(fileName, dirName) == true)
+ {
+ // skip subdirs from enumeration
+ const size_t idx = fileName.find(dirSeparator);
+ if (idx != std::string::npos)
+ fileName.erase(idx);
+ bool found(false);
+ FOR_EACH (StringVectCIter, itn, names)
+ {
+ if (*itn == fileName)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found == false)
+ {
+ std::string dirName2 = pathJoin(dirName, fileName);
+ if (findLast(dirName2, std::string(dirSeparator)) == false)
+ dirName2 += dirSeparator;
+ FOR_EACH (std::vector<std::string>::const_iterator,
+ it,
+ zipEntry->mDirs)
+ {
+ if (*it == dirName2)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (found == true)
+ names.push_back(fileName);
+ }
+ }
+ }
+ }
+ }
+
bool isDirectory(VirtFsEntry *restrict const entry,
const std::string &dirName,
bool &isDirFlag)