[Archive]TarThe streaming reader. each: (and the whole Iterate vocabulary over it) consumes the stream — one pass, in archive order.
var tar = [Archive]Tar.over:(([IO]File.open:'backup.tar').byteStream) tar.each:{ |e| ('%1 %2' % #( e.size e.name )).print }
A reader over a ByteStream — a file's, a socket's, or a gunzip-wrapped one for .tar.gz.
A writer onto a ByteStream — [IO]File.create:'s, a socket's, or a gzip-wrapped one for .tar.gz. See [Archive]TarWriter.
Read exactly size content bytes plus the block padding.
The current entry's content (guarded: current entry only, read once).
Yield each remaining entry in order; answers self. One pass — the Iterate vocabulary (select:, collect:, detect:, …) rides on this and consumes the stream the same way.
Extract every remaining FILE and DIRECTORY under dir (symlinks and specials are skipped). Member paths are normalized and confined: an absolute path or one escaping dir (../…) throws a ValueError — an archive must never write outside its target.
Internal.
mkdir -p: create each missing component (Folder.create: is idempotent).
The next entry, or nil at the end-of-archive marker. Skips the previous entry's unread content first.
An octal field: digits accumulate, spaces/NULs (the traditional padding) are skipped.
The path= value from a pax extended header: records are '<len> <key>=<value>\n' with len counting the whole record.
Skip the current entry's unread content, chunked — a passed-over entry may be huge, and skipping must not materialize it.
A NUL-terminated text field.
The ustar split name: prefix[345..500] + '/' + name[0..100].
The header checksum: every byte summed with the checksum field itself read as spaces. A mismatch means a corrupt or misaligned archive.