std.zip
Reads the archives of zip, as Windows, macOS and the forges make them: the files stored or compressed with deflate, also in the archives above 4 GB. read() gives the entries of an archive, and extract() writes them in a folder. It does not write archives, and it refuses the encrypted ones.
import std.fs
import std.zip
for (zip.Entry entry in zip.read(fs.readBytes("photos.zip"))) {
println("{}: {} bytes", entry.name, entry.data.len())
}
zip.extract(fs.readBytes("site.zip"), "site")The guide: Files, processes and time.
Generata dalla documentazione nei sorgenti della libreria, che è in inglese.
#Tipi
#Entry
struct EntryA file, a folder or a symbolic link of an archive.
string name: the path, with/and none at the end: "bin/cromo.exe"bool folder: whether it is a folderstring link: the target of a symbolic link, "" for the othersbool executable: whether it can run, by its permissions of Unix: false without themlist<u8> data: the content of a file, decompressed; empty for a folder or a link
#Funzioni
#read
list<Entry> read(list<u8> archive)The entries of an archive, in its order, with their content decompressed. Throws when the data are not a zip, or are damaged or cut: the CRC-32 of each file is checked. Throws also for a file that is encrypted, or compressed with a method other than deflate.
#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.