From e67b673e4ee9a50f03ba7c00426dfd0b636d85b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 11 Jan 2025 09:37:07 +0100 Subject: [PATCH] Fix regression in zip texture packs Can't seek in compressed zips. Let's add a comment too to not do this again. Thanks Nukem for debugging. --- Common/File/VFS/ZipFileReader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Common/File/VFS/ZipFileReader.cpp b/Common/File/VFS/ZipFileReader.cpp index 0c4de001fc..cf2d324f0e 100644 --- a/Common/File/VFS/ZipFileReader.cpp +++ b/Common/File/VFS/ZipFileReader.cpp @@ -290,8 +290,11 @@ VFSOpenFile *ZipFileReader::OpenFileForRead(VFSFileReference *vfsReference, size void ZipFileReader::Rewind(VFSOpenFile *vfsOpenFile) { ZipFileReaderOpenFile *file = (ZipFileReaderOpenFile *)vfsOpenFile; _assert_(file); + // Unless the zip file is compressed, can't seek directly, so we re-open. + // This version of libzip doesn't even have zip_file_is_seekable(), should probably upgrade. + zip_fclose(file->zf); + file->zf = zip_fopen_index(zip_file_, file->reference->zi, 0); _dbg_assert_(file->zf != nullptr); - zip_fseek(file->zf, 0, SEEK_SET); } size_t ZipFileReader::Read(VFSOpenFile *vfsOpenFile, void *buffer, size_t length) {