โ† index

[Archive]ZipWriter

inherits Object ยท defined at core/17-zip.qn:310

The writer, from [Archive]Zip.writeTo:. Writing streams naturally โ€” each member's local header + data go out as it is added (sizes and CRC are known up front, so no data descriptors), and close writes the central directory and end record, then closes the stream. Each member is stored or deflated, whichever is smaller โ€” what real zip tools do. Timestamps are the current local wall clock (DOS times have no zone). Close deliberately; an unclosed archive has no directory and no reader will accept it.

var zip = [Archive]Zip.writeTo:([IO]File.create:'backup.zip')
zip.add:'notes/today.txt' text:'ship the writer'
zip.addFile:'/var/log/build.log' as:'logs/build.log'
zip.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/17-zip.qn:320

add: data: dir:

Write one member: local header + data now, a central-directory record remembered for close.

core/17-zip.qn:382

add: text:String

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

core/17-zip.qn:323

addFile: as:

Add a file from disk under the archive name name. Zip needs the CRC and sizes before the data, so the content is read whole. Answers self.

core/17-zip.qn:333

addFolder:

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

core/17-zip.qn:326

close

End the archive: central directory, end record, close the stream. Idempotent. Returns nil.

core/17-zip.qn:337

init

Internal.

core/17-zip.qn:312

le16: into:

Little-endian emitters.

core/17-zip.qn:438

le32: into:

core/17-zip.qn:442

write:

Emit a byte list and advance the offset.

core/17-zip.qn:432