cromo La guida di Cromo
Scarica PDF EN

std.tar

Reads the archives of tar: the ustar of POSIX, with the long names of GNU and of pax, as GNU tar, bsdtar and the forges make them. read() gives the entries of an archive, and extract() writes them in a folder. A .tar.gz is first decompressed with std.gzip. It does not write archives.

cromo
import std.fs
import std.gzip
import std.tar

tar.extract(gzip.decompress(fs.readBytes("site.tar.gz")), "site")

The guide: Files, processes and time.

Generata dalla documentazione nei sorgenti della libreria, che è in inglese.

#Tipi

#Entry

cromo
struct Entry

A file, a folder or a symbolic link of an archive. A hard link becomes a copy of its file; the devices and the pipes are left out.

  • string name: the path, with / and none at the end: "bin/cromo"
  • bool folder: whether it is a folder
  • string link: the target of a symbolic link, "" for the others
  • bool executable: whether its permissions let it run
  • list<u8> data: the content of a file, empty for a folder or a link

#Funzioni

#read

cromo
list<Entry> read(list<u8> archive)

The entries of an archive, in its order, up to its end. Throws when the data are not a tar, or are damaged or cut: the checksum of each header is checked.

#extract

cromo
void extract(list<u8> archive, string folder)

Writes the files and the folders of the archive in folder, which is created if it is missing. A file that exists is replaced, and on Linux the executable ones get the permission to run. The links are left out, as they could point outside the folder, and a name that would leave it, as "../x" or "/x", stops the extraction with an exception: an archive that comes from the network cannot write elsewhere.