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 bytesearch_startin the file) for the end-of-central-directory signature and return its absolute file offset. - find_
zip64_ eocd_ offset - Scan
bufferfor 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) fromextra_buf. - parse_
zip64_ extra_ field - Parse a ZIP64 extra field (tag
0x0001) out ofextra_bufand return updated(uncompressed_size, compressed_size, offset).