Skip to content
FutureBlitz

    Install

    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.

    std/compress/zip.fb, line 38

    • Public Static Method Read(data: UInt8[]): ZipReader Throws IOError static method #

      A reader of the zip in data, which it copies, or an IOError of INVALID_DATA when the data isn't a zip.

    ZipMethod enum

    Public Enum ZipMethod

    How a ZipWriter compresses an entry.

    std/compress/zip.fb, line 49

    • STORE enum member #

      Stored as it is, not compressed.

    • DEFLATE enum member #

      Deflate, which every zip reader reads.

    • LZMA enum member #

      LZMA.

    • XZ enum member #

      XZ.

    • ZSTD enum member #

      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.

    std/compress/zip.fb, line 64

    • Public New() constructor #

      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 name of data, compressed by method, at level, or its default when level is 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 at modified, 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 is mode, or 644 when that's Null. Panics when the level isn't one of method's, when the mode isn't from 0 to 0o7777, or when the name is "", 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 at modified, as Add's are, with mode, or 755 when that's Null. Panics when the mode isn't from 0 to 0o7777, or when the name is "", holds a NUL or a '', or is longer than 65534 bytes.

    • @PanicsAtCaller Public Method Finish(): UInt8[] method #

      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.

    std/compress/zip.fb, line 159

    • Public Property Entries: ReadOnlyArray<ArchiveEntry> property #

      Its entries, in the order the zip has them.

    • Public Property Count: Int property #

      How many entries it has.

    • Public Method Find(name: String): ArchiveEntry? method #

      The entry named name, the last of them when there are several, or Null when there's none.

    • Public Method Contains(name: String): Bool method #

      Whether it has an entry named name.

    • Public Method Read(name: String): UInt8[]? Throws IOError method #

      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.

    • @PanicsAtCaller Public Method ReadAt(index: Int): UInt8[] Throws IOError method #

      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 the index is out of range.

    Report an issue with this page or with FutureBlitz on GitHub.