← index

[Archive]TarWriter

inherits Object · defined at core/15-tar.qn:307

The streaming writer, from [Archive]Tar.writeTo:. Members are written in call order as POSIX ustar; a name longer than 100 bytes gets a pax path= extended header (what the reader above and every system tar understand). Defaults are deliberate: mode 0644 (dirs 0755), uid/gid 0, mtime now (addFile:as: keeps the source file's). close writes the two zero end blocks and closes the stream — through the codec when it is gzip-wrapped, so .tar.gz needs no extra step. Close deliberately; an unclosed archive is missing its end marker.

var tar = [Archive]Tar.writeTo:(([IO]File.create:'backup.tar.gz').gzip)
tar.add:'notes/today.txt' text:'ship the writer'
tar.addFile:'/var/log/build.log' as:'logs/build.log'
tar.close

Instance methods

add: bytes:Bytes

Add one file member with the given content (bytes or, via add:text:, a UTF-8 String). Answers self.

core/15-tar.qn:316

add: text:String

add:bytes: for text: the content is the String's UTF-8 bytes.

core/15-tar.qn:324

addFile: as:

Add a file from disk under the archive name name, streamed in chunks — the content never materializes whole. Size and mtime come from the file's metadata snapshot; a file that proves shorter than its snapshot throws. Answers self.

core/15-tar.qn:337

addFolder:

Add a directory member (a trailing '/' is added if missing). Answers self.

core/15-tar.qn:327

checksum:

Sum the header with the checksum field as spaces, then write the sum as six octal digits, NUL, space — the traditional encoding.

core/15-tar.qn:448

close

End the archive: the two 512-byte zero end blocks, then close the stream (finishing a gzip wrap — the whole .tar.gz becomes valid here). Idempotent. Returns nil.

core/15-tar.qn:356

header: size: type: mode: mtime:

Write one 512-byte ustar header; a name over 100 bytes is carried in a pax path= extended header first, with the ustar field truncated.

core/15-tar.qn:367

init

Internal.

core/15-tar.qn:309

pad:

Pad the last content block out to 512 bytes.

core/15-tar.qn:410

paxPath:

The pax extended header ('x') whose one record overrides the next member's path: '<len> path=<value>\n', len counting the whole record.

core/15-tar.qn:393

put: octal: at: width:

A right-aligned, zero-padded, NUL-terminated octal field.

core/15-tar.qn:425

put: string: at:

Copy bytes into the header list at at.

core/15-tar.qn:416