Import std.compress.zip
std.compress.zip
Zip's archives, over minizip-ng: Zip.Read gives a ZipReader of a zip's entries, and a ZipWriter makes a new zip of entries stored or compressed by Deflate, LZMA, XZ, or Zstd; every zip tool reads Deflate's, and newer ones the rest. Zip64 comes in where sizes need it. Names are UTF-8: a zip's that don't say so, and aren't, are read as code page 437, as MS-DOS wrote them. A zip's encryption isn't supported. An entry's time is its extra fields', which say it in UTC, or else its DOS date's, read as UTC, as nothing says its zone; what a ZipWriter makes was last changed on 1980-01-01 unless it's told otherwise, so every program and OS makes the same bytes.
std/compress/zip.fb
Types
Zip
struct
Public Struct Zip
What makes and reads zip archives, in its Static Methods.
-
A reader of the zip in
data, which it copies, or an IOError of INVALID_DATA when thedataisn't a zip.
ZipMethod
enum
Public Enum ZipMethod
How a ZipWriter compresses an entry.
-
Stored as it is, not compressed.
-
Deflate, which every zip reader reads.
-
LZMA.
-
XZ.
-
Zstandard.
ZipWriter
class
Public Class ZipWriter
A new zip, an entry at a time: Add puts in a file, AddFolder a folder, and Finish gives the zip and starts again, empty.
-
A new ZipWriter, with no entries yet.
-
@PanicsAtCaller Public Method Add(name: String, data: UInt8[], method: ZipMethod = ZipMethod.DEFLATE, level: Int? = Null, modified: Timestamp? = Null, mode: Int? = Null)method #Adds a file named
nameofdata, compressed bymethod, atlevel, or its default whenlevelis Null: 6 for DEFLATE, from 0 to 9, and for LZMA and XZ, which a zip has from 1 to 9, as minizip-ng stores an entry at 0, and 3 for ZSTD, from 1 to 22. It was last changed atmodified, or on 1980-01-01 when that's Null, a DOS date of an even second from 1980 to 2107, which one from 1970 to 2106 is exact to the second beside, and its mode ismode, or 644 when that's Null. Panics when thelevelisn't one ofmethod's, when themodeisn't from 0 to 0o7777, or when thenameis "", holds a NUL or a '', ends with '/', as a folder's does, or is longer than 65535 bytes. -
@PanicsAtCaller Public Method AddFolder(name: String, modified: Timestamp? = Null, mode: Int? = Null)method #Adds a folder named
name, with '/' after it unless it has one, which takes 1 of a name's 65535 bytes, last changed atmodified, as Add's are, withmode, or 755 when that's Null. Panics when themodeisn't from 0 to 0o7777, or when thenameis "", holds a NUL or a '', or is longer than 65534 bytes. -
The zip, of the entries added since it started, and then it starts again, empty. Panics when it's more bytes than a UInt8[] holds.
ZipReader
class
Public Class ZipReader
A zip's entries, which Read gives the bytes of, from a copy of the zip's bytes.
-
Its entries, in the order the zip has them.
-
How many entries it has.
-
The entry named
name, the last of them when there are several, or Null when there's none. -
Whether it has an entry named
name. -
The bytes of the entry named
name, the last of them when there are several, or Null when there's none, as ReadAt gives them. -
The bytes of the entry at
index, which are none for a folder or a link, or an IOError when they're broken, encrypted, or compressed by a method that isn't supported. Panics when theindexis out of range.
Report an issue with this page or with FutureBlitz on GitHub.