code wiki / (root) / nx_zip_read.nx

nx_zip_read.nx

buildroot/runtime/nx_zip_read.nx

6108 B101 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic zip
docsdependenciesstructsconstsfunctions

about

nx_zip_read.nx -- SOVEREIGN ZIP reader (the first half of the PyTorch .bin loader). A PyTorch .bin is a ZIP archive of STORED (uncompressed) members: archive/data.pkl (the pickle describing the state_dict) + archive/ data/0, data/1, ... (raw tensor blobs) + archive/version. This finds the End-Of-Central-Directory record, walks the central directory, and lists every member (name / method / size / local-header offset), plus locates a member's raw data (STORED = data begins right after the local header). Tested on the REAL 50.7MB HiFi-GAN pytorch_model.bin just downloaded. Next: a minimal pickle-VM over data.pkl. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_zip_read.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main p sys_write sys_openat_rd sys_exit sys_mmap sys_read sys_close pn sys_write ↻ sys_mmap ↻ find_eocd u16le u32le pc sys_mmap ↻ sys_write ↻ member_data_off u16le ↻ sys_write ↻

structs

none

consts

8const K_MAGIC_67108864: i64 = 67108864

functions

10func p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
11func pn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d: *u8=sys_mmap(24); var k: i64=0; while m>0 {d[k]=(48+(m%10)) as u8; m=m/10; k=k+1} var i: i64=k-1; while i>=0 {let o: *u8=sys_mmap(1); o[0]=d[i]; sys_write(1,o,1); i=i-1} return 0 }
called by 1: main calls 2: sys_writesys_mmap
12func pc(c: i64) -> i64 { let o: *u8=sys_mmap(1); o[0]=c as u8; sys_write(1,o,1); return 0 }
called by 1: main calls 2: sys_mmapsys_write
14func u16le(b: *u8, o: i64) -> i64 { return (b[o]&0xff) | ((b[o+1]&0xff)<<8) }
called by 2: member_data_offmain
15func u32le(b: *u8, o: i64) -> i64 { return (b[o]&0xff) | ((b[o+1]&0xff)<<8) | ((b[o+2]&0xff)<<16) | ((b[o+3]&0xff)<<24) }
called by 1: main
18func find_eocd(b: *u8, n: i64) -> i64
called by 1: main
27func member_data_off(b: *u8, lho: i64) -> i64
called by 1: main calls 1: u16le
33func main() -> i64