[Archive]ZipWriterThe 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
Add one file member with the given content (bytes or, via add:text:, a UTF-8 String). Answers self.
Write one member: local header + data now, a central-directory record remembered for close.
add:bytes: for text: the content is the String's UTF-8 bytes.
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.
Add a directory member (a trailing '/' is added if missing). Answers self.
End the archive: central directory, end record, close the stream. Idempotent. Returns nil.
Internal.
Little-endian emitters.
Emit a byte list and advance the offset.