Import with #import "std/zip".

ZipEntry :: struct { data_start: u64; compressed_size: u64; size: u64; crc32: u32; method: u32; found: bool; }
ZipDirectory :: struct { start: u64; end: u64; cursor: u64; count: u64; index: u64; valid: bool; }
ZipNamedEntry :: struct { directory: ZipDirectory; entry: ZipEntry; name_start: u64; name_size: u64; valid: bool; }
ZipWriteItem :: struct { name_start: u64; name_size: u64; data_start: u64; data_size: u64; }
ZipU16 :: (bytes: []u8, at: u64) -> u32
ZipU32 :: (bytes: []u8, at: u64) -> u32
ZipNameEqual :: (bytes: []u8, at: u64, size: u64, wanted: string) -> bool
OpenZipDirectory :: (bytes: []u8) -> ZipDirectory
ZipNamesMatch :: (bytes: []u8, first: u64, second: u64, size: u64) -> bool
NextZipEntry :: (bytes: []u8, directory: ZipDirectory) -> ZipNamedEntry

On malformed input, both the returned record and the cursor become invalid.

FindZipEntry :: (bytes: []u8, wanted: string) -> ZipEntry

A missing or invalid entry has found=false. Duplicate names are invalid.

ZipCRC32Update :: (crc_start: u32, bytes: []u8) -> u32
ZipCRC32 :: (bytes: []u8) -> u32
CopyStoredZipEntry :: (bytes: []u8, entry: ZipEntry, output: []u8) -> bool
ZipPut16 :: (output: []u8, at: u64, value: u32)
ZipPut32 :: (output: []u8, at: u64, value: u32)
StoredZipSize :: (input: []u8, items: []ZipWriteItem) -> u64

Returns the exact output size or zero when classic ZIP limits are exceeded.

ZipCopyBytes :: (output: []u8, at: u64, input: []u8, input_at: u64, size: u64)
ZipCRC32Range :: (bytes: []u8, at: u64, size: u64) -> u32
WriteStoredZip :: (output: []u8, input: []u8, items: []ZipWriteItem) -> u64

Writes uncompressed ZIP entries into caller-owned memory. An app can choose compression separately; this keeps the archive format portable and usable even where no native compression library is installed.

Source ↗ · All modules