diff options
Diffstat (limited to 'src/fs/zip.cpp')
-rw-r--r-- | src/fs/zip.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/fs/zip.cpp b/src/fs/zip.cpp index cff4a3e6f..62b60a451 100644 --- a/src/fs/zip.cpp +++ b/src/fs/zip.cpp @@ -20,7 +20,7 @@ #include "fs/zip.h" -#include "fs/virtfile.h" +#include "fs/virtzipentry.h" #include "fs/ziplocalheader.h" #include "utils/checkutils.h" @@ -46,9 +46,16 @@ namespace Zip { - bool readArchiveInfo(const std::string &restrict archiveName, - std::vector<ZipLocalHeader*> &restrict headers) + bool readArchiveInfo(VirtZipEntry *const entry) { + if (entry == nullptr) + { + reportAlways("Entry is null."); + return false; + } + const std::string archiveName = entry->mArchiveName; + std::vector<ZipLocalHeader*> &restrict headers = entry->mHeaders; + std::vector<std::string> &restrict dirs = entry->mDirs; FILE *restrict const arcFile = fopen(archiveName.c_str(), "r"); if (arcFile == nullptr) @@ -78,7 +85,7 @@ namespace Zip buf[3] == 0x04) { // local file header header = new ZipLocalHeader; - header->archiveName = archiveName; + header->zipEntry = entry; // skip useless fields fseek(arcFile, 4, SEEK_CUR); // + 4 // file header pointer on 8 @@ -131,6 +138,11 @@ namespace Zip logger->log(" uncompressed size: %u", header->uncompressSize); } + else + { + dirs.push_back(header->fileName); + delete header; + } } else if (buf[0] == 0x50 && buf[1] == 0x4B && @@ -197,12 +209,13 @@ namespace Zip reportAlways("Zip::readCompressedFile: header is null"); return nullptr; } - FILE *restrict const arcFile = fopen(header->archiveName.c_str(), + FILE *restrict const arcFile = fopen( + header->zipEntry->mArchiveName.c_str(), "r"); if (arcFile == nullptr) { reportAlways("Can't open zip file %s", - header->archiveName.c_str()); + header->zipEntry->mArchiveName.c_str()); return nullptr; } @@ -213,7 +226,7 @@ namespace Zip compressSize) { reportAlways("Read zip compressed file error from archive: %s", - header->archiveName.c_str()); + header->zipEntry->mArchiveName.c_str()); fclose(arcFile); delete [] buf; return nullptr; @@ -251,7 +264,7 @@ namespace Zip int ret = inflateInit2(&strm, -MAX_WBITS); if (ret != Z_OK) { - reportZlibError(header->archiveName, ret); + reportZlibError(header->zipEntry->mArchiveName, ret); delete [] in; delete [] out; return nullptr; |