summaryrefslogtreecommitdiff
path: root/src/fs/virtfszip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/virtfszip.cpp')
-rw-r--r--src/fs/virtfszip.cpp48
1 files changed, 40 insertions, 8 deletions
diff --git a/src/fs/virtfszip.cpp b/src/fs/virtfszip.cpp
index 35b94c780..dc8223b6f 100644
--- a/src/fs/virtfszip.cpp
+++ b/src/fs/virtfszip.cpp
@@ -274,17 +274,17 @@ namespace VirtFsZip
if (findLast(dirName, std::string(dirSeparator)) == false)
dirName += dirSeparator;
StringVect &names = list->names;
- FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
+ if (dirName == "/")
{
- VirtZipEntry *const entry = *it;
- FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
- it2,
- entry->mHeaders)
+ FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
{
- ZipLocalHeader *const header = *it2;
- std::string fileName = header->fileName;
- if (findCutFirst(fileName, dirName) == true)
+ VirtZipEntry *const entry = *it;
+ FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
+ it2,
+ entry->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)
@@ -303,6 +303,38 @@ namespace VirtFsZip
}
}
}
+ else
+ {
+ FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries)
+ {
+ VirtZipEntry *const entry = *it;
+ FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator,
+ it2,
+ entry->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)
+ names.push_back(fileName);
+ }
+ }
+ }
+ }
return list;
}