MemoryData ZipReader::ReadAllData(StringRef fileName)const { MemoryData result; if (mZipFile==nullptr||fileName.IsEmpty()) { return result; } const ZipFileInfo* zipEntryInfo=mFileDict.TryGetByOtherKey(fileName,fileName.HashCode()); if (zipEntryInfo==nullptr) { return result; } int err = unzGoToFilePos(mZipFile, (unz_file_pos*)&zipEntryInfo->Pos); if (err!=UNZ_OK) { return result; } err = unzOpenCurrentFile(mZipFile); if (err!=UNZ_OK) { return result; } result=MemoryData::Alloc(zipEntryInfo->UncompressedSize); int readSize = unzReadCurrentFile(mZipFile, result.MutableData(), (uint)zipEntryInfo->UncompressedSize); Log::Assert(readSize==(int)zipEntryInfo->UncompressedSize,"Invalid zip file size."); //readSize could be 0 because we may have zero file such as "StringTable-enus.bin" unzCloseCurrentFile(mZipFile); return result; }
bool ZipReader::Exists(StringRef fileName) const { return mFileDict.ContainsOtherKey(fileName,fileName.HashCode()); }