[Archive]ZipThe reader. Construction parses the end-of-central-directory record and the central directory eagerly (they are small); content stays on the source until asked for.
var zip = [Archive]Zip.open:'backup.zip' zip.each:{ |e| ('%1 %2' % #( e.size e.name )).print } (zip.at:'notes/today.txt').text zip.close
A reader over any random-access source — something answering readAt:offset count: and size (a RandomAccessFile, or Bytes).
A reader over the file at path, via randomAccess — the central directory and each entry read by offset; nothing loaded whole.
A writer onto a ByteStream — [IO]File.create:'s, or a socket's. See [Archive]ZipWriter.
The entry named exactly name, or nil.
Close the underlying source (a no-op over Bytes). Entries' bytes throw after this.
The current entry's content: local header re-read for the true data offset (its extra field can differ from the central directory's), decompress, verify.
The member count.
Yield each entry in order; answers self. The Iterate vocabulary (select:, collect:, detect:, …) rides on this.
Every member, in central-directory order. A plain List — address freely.
An EOCD candidate at pos: signature PK 05 06, and its comment-length field must run exactly to the end of the file — the disambiguator when the signature bytes happen to appear in a comment.
Extract every FILE and DIRECTORY member under dir (specials are skipped — zip has none to speak of). Member paths are normalized and confined exactly as [Archive]Tar's: an absolute path or one escaping dir throws a ValueError before anything lands outside.
Internal: locate the EOCD (scan the tail window backward — it ends with a variable-length comment), refuse what v1 doesn't speak (multi-disk, zip64), then walk the central directory into the entry list.
mkdir -p (the tar reader's twin).
Exact read through the random-access protocol; short means truncated.
Little-endian fields.