← index

[Archive]Zip

inherits Object · mixes in Iterate · defined at core/17-zip.qn:96

The 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

Class methods

of:

A reader over any random-access source — something answering readAt:offset count: and size (a RandomAccessFile, or Bytes).

core/17-zip.qn:102

open:

A reader over the file at path, via randomAccess — the central directory and each entry read by offset; nothing loaded whole.

core/17-zip.qn:106

writeTo:

A writer onto a ByteStream — [IO]File.create:'s, or a socket's. See [Archive]ZipWriter.

core/17-zip.qn:110

Instance methods

at:

The entry named exactly name, or nil.

core/17-zip.qn:185

close

Close the underlying source (a no-op over Bytes). Entries' bytes throw after this.

core/17-zip.qn:196

contentFor:

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.

core/17-zip.qn:228

count

The member count.

core/17-zip.qn:182

each:

Yield each entry in order; answers self. The Iterate vocabulary (select:, collect:, detect:, …) rides on this.

core/17-zip.qn:189

entries

Every member, in central-directory order. A plain List — address freely.

core/17-zip.qn:179

eocd?: at: windowLen:

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.

core/17-zip.qn:274

extractTo:

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.

core/17-zip.qn:202

init

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.

core/17-zip.qn:116

mkdirs:

mkdir -p (the tar reader's twin).

core/17-zip.qn:283

read: count:

Exact read through the random-access protocol; short means truncated.

core/17-zip.qn:258

u16: at:

Little-endian fields.

core/17-zip.qn:265

u32: at:

core/17-zip.qn:266