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.
-
A reader of the tar in
data, or in thedatadecompressed 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.
-
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
nameofdata, last changed atmodified, or at 1970's start when that's Null, and withmode, or 644 when that's Null. Panics when themodeisn't from 0 to 0o7777, or when thenameis "", 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 atmodified, as Add's are, withmode, or 755 when that's Null. Panics when themodeisn't from 0 to 0o7777, or when thenameis "" or holds a NUL. -
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.
-
Its entries, in the order the tar 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, or are a GNU sparse file's, which isn't supported. Panics when theindexis out of range.
Report an issue with this page or with FutureBlitz on GitHub.