diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-28 20:13:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-02-28 20:13:55 +0300 |
commit | 993e6f9b9606a71ad35302f0767017fd426c1d0e (patch) | |
tree | 13a8bc658412348d8ea2d248b8d6b6a684f1e541 /src/fs/virtfszip.cpp | |
parent | c33ecc43f775eebae66e5ad0dc5f9588162b3783 (diff) | |
download | manaverse-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.gz manaverse-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.bz2 manaverse-993e6f9b9606a71ad35302f0767017fd426c1d0e.tar.xz manaverse-993e6f9b9606a71ad35302f0767017fd426c1d0e.zip |
Fix files enumeration in root directory in VirtFsZip.
Also add tests for same for other VirtFs functions.
Diffstat (limited to 'src/fs/virtfszip.cpp')
-rw-r--r-- | src/fs/virtfszip.cpp | 48 |
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; } |