code wiki / (root) / nx_zip_header.nx

nx_zip_header.nx

buildroot/runtime/nx_zip_header.nx

7707 B210 linesdepth 2pulls 2 transitivereach 20 importersview sourcekind tooltopic zip
docsdependenciesstructsconstsfunctions

about

zip_header.nx -- parse PKZIP APPNOTE 6.3.x framing. Parses two key structures in a .zip archive: 1. Local File Header (LFH) -- one per stored file, prefixes each compressed payload. Signature 0x04034b50. 2. End of Central Directory record (EOCD) -- at the tail of the archive; points to the central directory. Signature 0x06054b50. This module does NOT parse the central directory entries (CDFH) or decompress payloads. With just LFH + EOCD the Nishi stack can: detect zip framing, count members, read filenames, identify compression method (0=stored, 8=DEFLATE, 14=LZMA, 93=Zstd...), and find the offset of each file's raw bytes. All multi-byte values in ZIP are little-endian. Invariants: Z1 LFH signature must be 0x04034b50. Z2 EOCD signature must be 0x06054b50 (may be preceded by a variable-length ZIP comment; caller scans backward). Z3 Filenames are stored raw; if bit 11 of general-purpose flag is set, they are UTF-8; otherwise CP437. We expose offset+length and let caller decide. Z4 Compressed-size / uncompressed-size may be 0xFFFFFFFF to indicate Zip64 extensions; we surface that as a sentinel for now.

dependencies 1 imports · 2 importers

nx_syscalls.nx nx_zip_header.nx nx_opc.nx nx_safe_archive_ingest.nx

imports: nx_syscalls.nx

imported by: nx_opc.nxnx_safe_archive_ingest.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap zip_parse_lfh zip_read_u32 zip_read_u16 zip_find_eocd zip_read_u32 ↻ zip_parse_eocd zip_read_u32 ↻ zip_read_u16 ↻ zip_method_known

structs

46struct ZipLocalHeader
61struct ZipEndOfCentralDir

consts

36const ZIP_MAGIC_66000: i64 = 66000
38const ZIP_LFH_SIG: i64 = 0x04034b50
39const ZIP_EOCD_SIG: i64 = 0x06054b50
41const ZIP_ERR_FORMAT: i64 = -1
42const ZIP_ERR_SHORT: i64 = -2
44const ZIP64_MARKER: i64 = 0xFFFFFFFF

functions

73func zip_read_u16(buf: *u8, off: i64) -> i64
77func zip_read_u32(buf: *u8, off: i64) -> i64
87func zip_parse_lfh(buf: *u8, n: i64, off: i64, h: *ZipLocalHeader) -> i64
115func zip_find_eocd(buf: *u8, n: i64) -> i64
called by 2: mainmain calls 1: zip_read_u32
130func zip_parse_eocd(buf: *u8, n: i64, off: i64,
called by 2: mainmain calls 2: zip_read_u32zip_read_u16
151func zip_method_known(method: i64) -> i64
called by 1: main
162func main() -> i64