nx_zip_header.nx
buildroot/runtime/nx_zip_header.nx
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
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
structs
| 46 | struct ZipLocalHeader |
| 61 | struct ZipEndOfCentralDir |
consts
| 36 | const ZIP_MAGIC_66000: i64 = 66000 |
| 38 | const ZIP_LFH_SIG: i64 = 0x04034b50 |
| 39 | const ZIP_EOCD_SIG: i64 = 0x06054b50 |
| 41 | const ZIP_ERR_FORMAT: i64 = -1 |
| 42 | const ZIP_ERR_SHORT: i64 = -2 |
| 44 | const ZIP64_MARKER: i64 = 0xFFFFFFFF |
functions
| 73 | func zip_read_u16(buf: *u8, off: i64) -> i64 |
| 77 | func zip_read_u32(buf: *u8, off: i64) -> i64 |
| 87 | func zip_parse_lfh(buf: *u8, n: i64, off: i64, h: *ZipLocalHeader) -> i64 |
| 115 | func zip_find_eocd(buf: *u8, n: i64) -> i64 |
| 130 | func zip_parse_eocd(buf: *u8, n: i64, off: i64, |
| 151 | func zip_method_known(method: i64) -> i64 called by 1: main |
| 162 | func main() -> i64 |