From a6300c3b29f96f0913a788287ae88524c5db4db7 Mon Sep 17 00:00:00 2001 From: Nathan Moin Vaziri Date: Sun, 26 Apr 2026 18:47:40 -0700 Subject: [PATCH] compat: add unzGetCurrentFileZStreamPos64 (#848) Returns the absolute offset where the current entry's compressed data begins, matching the original minizip API used by chromium and other consumers. The position is already tracked internally via entry_pos for STORE-method seek support, so this just exposes it. --- compat/unzip.c | 7 +++++++ compat/unzip.h | 1 + 2 files changed, 8 insertions(+) diff --git a/compat/unzip.c b/compat/unzip.c index 3fa2e40..27bc670 100644 --- a/compat/unzip.c +++ b/compat/unzip.c @@ -629,6 +629,13 @@ int unzSetOffset64(unzFile file, int64_t pos) { return (int)mz_zip_goto_entry(compat->handle, pos); } +uint64_t unzGetCurrentFileZStreamPos64(unzFile file) { + mz_unzip_compat *compat = (mz_unzip_compat *)file; + if (!compat || mz_zip_entry_is_open(compat->handle) != MZ_OK) + return 0; + return (uint64_t)compat->entry_pos; +} + int unzGetLocalExtrafield(unzFile file, void *buf, unsigned int len) { mz_unzip_compat *compat = (mz_unzip_compat *)file; mz_zip_file *file_info = NULL; diff --git a/compat/unzip.h b/compat/unzip.h index c4b707c..28548ab 100644 --- a/compat/unzip.h +++ b/compat/unzip.h @@ -217,6 +217,7 @@ ZEXPORT int64_t unzGetOffset64(unzFile file); ZEXPORT unsigned long unzGetOffset(unzFile file); ZEXPORT int unzSetOffset64(unzFile file, int64_t pos); ZEXPORT int unzSetOffset(unzFile file, unsigned long pos); +ZEXPORT uint64_t unzGetCurrentFileZStreamPos64(unzFile file); ZEXPORT int32_t unztell(unzFile file); ZEXPORT uint64_t unztell64(unzFile file); ZEXPORT int unzeof(unzFile file);