diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-02 00:27:17 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-02 00:27:17 +0300 |
commit | 32061bfe63fce77accf1657a6631700c859fa541 (patch) | |
tree | 62ad40c3b71ab01295651fbfdfdd9547060bcc9f /src/fs/virtfs/virtfszip.cpp | |
parent | 4998ec60e1f065a91fd45de2aea20c4d5a002a43 (diff) | |
download | mv-32061bfe63fce77accf1657a6631700c859fa541.tar.gz mv-32061bfe63fce77accf1657a6631700c859fa541.tar.bz2 mv-32061bfe63fce77accf1657a6631700c859fa541.tar.xz mv-32061bfe63fce77accf1657a6631700c859fa541.zip |
Fix some issues in virtfs and update tests.
Diffstat (limited to 'src/fs/virtfs/virtfszip.cpp')
-rw-r--r-- | src/fs/virtfs/virtfszip.cpp | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/fs/virtfs/virtfszip.cpp b/src/fs/virtfs/virtfszip.cpp index c4ce6f9e8..425883f6d 100644 --- a/src/fs/virtfs/virtfszip.cpp +++ b/src/fs/virtfs/virtfszip.cpp @@ -67,7 +67,34 @@ namespace VirtFsZip entry->mHeaders) { if ((*it2)->fileName == filename) - return *it2;; + return *it2; + } + } + return nullptr; + } + + VirtZipEntry *searchZipEntryByNameWithDir(const std::string &restrict + filename) + { + std::string dirName = filename; + if (findLast(dirName, std::string(dirSeparator)) == false) + dirName += dirSeparator; + FOR_EACH (std::vector<VirtZipEntry*>::const_iterator, it, mEntries) + { + VirtZipEntry *const entry = *it; + FOR_EACH (std::vector<ZipLocalHeader*>::const_iterator, + it2, + entry->mHeaders) + { + if ((*it2)->fileName == filename) + return entry; + } + FOR_EACH (std::vector<std::string>::const_iterator, + it2, + entry->mDirs) + { + if (*it2 == dirName) + return entry; } } return nullptr; @@ -246,9 +273,10 @@ namespace VirtFsZip std::string getRealDirInternal(const std::string &filename) { - ZipLocalHeader *restrict const header = searchHeaderByName(filename); - if (header != nullptr) - return header->zipEntry->mArchiveName; + VirtZipEntry *restrict const entry = searchZipEntryByNameWithDir( + filename); + if (entry != nullptr) + return entry->mArchiveName; return std::string(); } @@ -261,10 +289,9 @@ namespace VirtFsZip name.c_str()); return false; } - ZipLocalHeader *restrict const header = searchHeaderByName(name); - if (header != nullptr) - return true; - return false; + VirtZipEntry *restrict const entry = searchZipEntryByNameWithDir( + name); + return entry != nullptr; } VirtList *enumerateFiles(std::string dirName) |