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.
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.
Made from the documentation in the sources of the library.
#Types
#Entry
struct EntryA 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 folderstring link: the target of a symbolic link, "" for the othersbool executable: whether its permissions let it runlist<u8> data: the content of a file, empty for a folder or a link
#Functions
#read
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
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.