Skip to content
FutureBlitz

    Install

    Import std.compress.tar

    std.compress.tar

    Tar's archives: Tar.Read gives a TarReader of a tar's entries, and a TarWriter makes a new tar. A .tar.gz, .tar.zst, .tar.xz, or .tar.lz4 reads as its tar, which Tar.Read decompresses first, and a TarWriter's tar compresses to one, as Gzip.Compress(writer.Finish()) does. It reads POSIX's ustar, with pax's extended headers, GNU's long names and large numbers, and old tars without a magic, and leaves out devices and FIFOs. Names are UTF-8, with U+FFFD for each byte of one that isn't. An entry's time is a pax header's, which can be before 1970 and has a fraction, or else its header's. A TarWriter writes ustar, with a pax header for a name ustar can't hold or that isn't ASCII, or a time it can't, owned by root: unless it's told otherwise, a file's mode is 644 and a folder's 755, at 1970's start, so every program and OS makes the same bytes.

    std/compress/tar.fb

    Types

    Tar struct

    Public Struct Tar

    What makes and reads tar archives, in its Static Methods.

    std/compress/tar.fb, line 43

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

      A reader of the tar in data, or in the data decompressed when it starts as Gzip's, Zstd's, XZ's, or LZ4's does, which it copies, or an IOError when it isn't a tar, or its compression is broken. A decompressed tar holds no more bytes than an array does.

    TarWriter class

    Public Class TarWriter

    A new tar, an entry at a time: Add puts in a file, AddFolder a folder, and Finish gives the tar and starts again, empty.

    std/compress/tar.fb, line 58

    • Public New() constructor #

      A new TarWriter, with no entries yet.

    • @PanicsAtCaller Public Method Add(name: String, data: UInt8[], modified: Timestamp? = Null, mode: Int? = Null) method #

      Adds a file named name of data, last changed at modified, or at 1970's start when that's Null, and with mode, or 644 when that's Null. Panics when the mode isn't from 0 to 0o7777, or when the name is "", holds a NUL, or ends with '/', as a folder's does.

    • @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, 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 "" or holds a NUL.

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

      The tar, of the entries added since it started, and then it starts again, empty. Panics when it's more bytes than a UInt8[] holds.

    TarReader class

    Public Class TarReader

    A tar's entries, which Read gives the bytes of, from a copy of the tar's bytes.

    std/compress/tar.fb, line 144

    • Public Property Entries: ReadOnlyArray<ArchiveEntry> property #

      Its entries, in the order the tar 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, or are a GNU sparse file's, which isn't supported. Panics when the index is out of range.

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