Skip to content

std/zip ​

Read PKZIP archives (APPNOTE.TXT), pure Milo over std/inflate. Reads the central directory, then for each entry inflates the payload — stored (method 0) is copied, deflate (method 8) is inflated — and verifies each entry's CRC-32 against the directory.

Read-only and whole-archive (no streaming, no zip64, no encryption) — enough to open .zip / .jar / .epub / .docx.

milo
from "std/zip" import { Zip }

Example ​

milo
from "std/fs" import { readFile }

let bytes = readFile("archive.zip")!
for entry in Zip.read(bytes)! {
    print($"{entry.name}: {entry.data.len} bytes")
}

API reference ​

Zip ​

milo
pub struct Zip

Zip namespace — Zip.read(src) parses a PKZIP archive into entries.

Zip.read ​

milo
fn Zip.read(src: &string): Result<Vec<ZipEntry>, string>

Read every entry, decompressing and CRC-checking each. Errs on a malformed archive, an unsupported compression method, or a CRC mismatch.

ZipEntry ​

milo
pub struct ZipEntry

One archive member: its stored name and its decompressed data.

Fields:

  • name: string
  • data: string: decompressed contents