std.zip
read and write .zip (stored or DEFLATE); also .docx, .xlsx, .jar, .epub
no zip64 (> 4 GB or 65535 entries), encryption or other methods: unsupported
ZipError
Section titled “ZipError”pub ZipError :: errors { not_zip, corrupt, unsupported, bad_checksum,}not_zip: no end record: not a zip, or truncatedcorrupt: record out of bounds or bad signatureunsupported: zip64, encryption, or not stored/DEFLATEbad_checksum: CRC-32 or size mismatch
pub Entry :: struct { name: []const u8, method: u16, crc: u32, compressed_size: u64, size: u64, header_offset: u64, is_dir: bool, flags: u16, dos_time: u16, dos_date: u16,}file or folder, as the central directory lists it
method: 0 stored, 8 DEFLATEheader_offset: where its local header isis_dir: a name that ends in “/”
Entry.modified
Section titled “Entry.modified”pub modified :: fn(self: *Self) -> i64unix seconds from the DOS date/time: local time, 2 s resolution
Archive
Section titled “Archive”pub Archive :: struct { data: []const u8, entries: []Entry,}entries in central-directory order
Archive.find
Section titled “Archive.find”pub find :: fn(self: *Self, name: []const u8) -> ?EntryArchive.read
Section titled “Archive.read”pub read :: fn(self: *Self, a: *Arena, e: Entry) -> []const u8 ! ZipErrorcontents in a; CRC-32 and size checked
pub open :: fn(a: *Arena, data: []const u8) -> Archive ! ZipErrordata is the whole .zip in memory; entries listed in a
Writer
Section titled “Writer”pub Writer :: struct { region: *Arena, out: Vec(u8), entries: Vec(Entry),}archive being written; finish gives its bytes
Writer.add
Section titled “Writer.add”pub add :: fn(self: *Self, name: []const u8, data: []const u8, level: u32)level 0 stores; dated 1980-01-01
Writer.add_at
Section titled “Writer.add_at”pub add_at :: fn(self: *Self, name: []const u8, data: []const u8, level: u32, unix_secs: i64)zip dates are local, no zone, 2 s steps: pass secs + time::local_offset(secs)
Writer.add_dir
Section titled “Writer.add_dir”pub add_dir :: fn(self: *Self, name: []const u8)appends “/” if missing
Writer.finish
Section titled “Writer.finish”pub finish :: fn(self: *Self) -> []const u8added data, then the central directory and end record
writer
Section titled “writer”pub writer :: fn(a: *Arena) -> Writerempty archive in a