archive/zip
lib/archive/zip.vklib/archive/zip.vk
Pure-Veko PKZIP .zip archive codec supporting STORE (0) and DEFLATE (8)
compression (compress/deflate), CRC-32 verification (bits/crc32), and
path-traversal confinement. Zero capabilities required.
ZipEntry = struct { path str, data bytes, compress bool = ... }
Single file entry stored in a .zip archive.
pack = fn [entries block[ZipEntry]] bytes
Packs entries into a standard PKZIP .zip archive (auto-falling back to STORE if DEFLATE is larger).
Executable Example
use [zip = archive/zip]
raw = zip/pack [
zip/ZipEntry { path = 'readme.txt', data = bytes/from-str 'hello veko zip hello veko zip hello veko zip' }
zip/ZipEntry { path = 'raw.bin', data = bytes/from-str 'abc', compress = false }
]
out = zip/unpack raw
if (len out) != 2 or (bytes/to-str out[0].data) != 'hello veko zip hello veko zip hello veko zip' or (bytes/to-str out[1].data) != 'abc' [
err 'zip roundtrip'
] else [ .ok ]
unpack = fn [raw bytes] block[ZipEntry]
Unpacks a .zip archive via its Central Directory, decompressing DEFLATE entries and verifying CRC-32 checksums.