diff options
Diffstat (limited to 'src/fs/virtfs/virtfszip.cpp')
-rw-r--r-- | src/fs/virtfs/virtfszip.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp index f2cacc34f..ae31f2606 100644 --- a/src/fs/virtfs/virtfszip.cpp +++ b/src/fs/virtfs/virtfszip.cpp @@ -21,6 +21,7 @@ #include "fs/virtfs/virtfszip.h" #include "fs/virtfs/virtfile.h" +#include "fs/virtfs/virtfs.h" #include "fs/virtfs/virtfsfuncs.h" #include "fs/virtfs/virtfsziprwops.h" #include "fs/virtfs/virtlist.h" @@ -73,6 +74,7 @@ namespace VirtFsZip ptr->openWrite = &VirtFsZip::openWrite; ptr->openAppend = &VirtFsZip::openAppend; ptr->loadFile = &VirtFsZip::loadFile; + ptr->getFiles = &VirtFsZip::getFiles; ptr->rwops_seek = &VirtFsZip::rwops_seek; ptr->rwops_read = &VirtFsZip::rwops_read; ptr->rwops_write = &VirtFsZip::rwops_write; @@ -193,6 +195,98 @@ namespace VirtFsZip } } + void getFiles(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 == false) + 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 == false) + names.push_back(fileName); + } + } + } + } + } + bool isDirectory(VirtFsEntry *restrict const entry, const std::string &dirName, bool &isDirFlag) |