Skip to main content

Module format

Module format 

Source
Expand description

Shared ZIP format constants, types, and pure parsing helpers.

Both reader and async_reader import from here to avoid duplicating ~600 lines of identical ZIP parsing logic. None of the functions in this module perform I/O — they only operate on already-read byte slices so they can be used in both the sync and async code paths without any adaptation.

Structs§

ZipEntry
Entry in a ZIP central directory.

Constants§

CENTRAL_DIRECTORY_SIGNATURE
ZIP central directory entry signature (PK\x01\x02)
END_OF_CENTRAL_DIRECTORY_SIGNATURE
ZIP end-of-central-directory signature (PK\x05\x06)
LOCAL_FILE_HEADER_SIGNATURE
ZIP local file header signature (PK\x03\x04)
MAX_ENTRY_ALLOC
Maximum single-entry allocation (2 GiB).
ZIP64_END_OF_CENTRAL_DIRECTORY_SIGNATURE
ZIP64 end-of-central-directory record signature (PK\x06\x06)

Functions§

find_eocd_in_buffer
Scan buffer (which starts at byte search_start in the file) for the end-of-central-directory signature and return its absolute file offset.
find_zip64_eocd_offset
Scan buffer for the ZIP64 EOCD locator signature (PK\x06\x07) and return the absolute file offset of the ZIP64 EOCD record encoded inside the locator.
parse_aes_extra_field_buf
Parse WinZip AES extra field (ID 0x9901) from extra_buf.
parse_zip64_extra_field
Parse a ZIP64 extra field (tag 0x0001) out of extra_buf and return updated (uncompressed_size, compressed_size, offset).