Archiving
The functions for working with zip and tar.gz archives are described here.

The ArchiveName function concatenates the Name and Dir fields in a variable of finfo type and returns the file path for the archive relative to the root path root.

The CloseTarGz function finishes creating the .tar.gz archive. The h parameter is the identifier that was returned by the CreateTarGz function.

The CloseZip function finishes creating the .zip archive. The h parameter is the identifier that was returned by the CreateZip function.

The CreateTarGz function starts creating a .tar.gz archive with the specified name. You can add files to this archive with the CompressFile function. The function returns an identifier, which you will need to close with the CloseTarGz function.

The CreateZip function starts creating a .tar.gz archive with the specified name. You can add files to this archive with the CompressFile function. The function returns an identifier, which you will need to close with the CloseZip function.

The CompressFile function adds the specified fname file to the created archive. The packname parameter contains the relative path and file name to be saved in the archive. Use / symbol as a separator. The archive must be previously created using the CreateZip or CreateTarGz functions.
handle zip = CreateZip(`my.zip`)
CompressFile(zip, `../data/my.txt`, `my.txt`)
CompressFile(zip, `/home/user/folder/copy.txt`, `folder/copy.txt`)
CloseZip(zip)

The ReadTarGz function returns the list of files in the specified tar.gz archive. The Name field contains the file name together with the relative path.
arr.finfo list = ReadTarGz(`my.tar.gz`)
for fi in list : Println( "\{fi.Name} \{fi.Size}")

The ReadZip function returns the list of files in the specified .zip archive. The Name field contains the file name together with the relative path.

The TarGz function packs the file or the contents of the path directory into a .tar.gz archive named name.
TarGz("/home/user/out/my.tar.gz", `/home/user/docs`)

The UnpackTarGz function unpacks a .tar.gz archive named name into the path directory.
UnpackTarGz("/home/user/out/my.tar.gz", `/home/user/olddocs`)

The UnpackTarGz function selectively unpacks a .tar.gz archive named name into the path directory. The pattern array contains file patterns to be unpacked. The ignore array contains file patterns to skip. The pattern and ignore parameters can be empty arrays. If the pattern begins and ends with /, then it is treated as a regular expression.
arr empty
arr doc = {`*.docx`, `/.txt$/`}
UnpackTarGz("/home/user/out/my.tar.gz", `/home/user/tmp`, doc, empty )

The UnpackZip function unpacks a .zip archive named name into the path directory.
UnpackZip("/home/user/out/my.zip", `/home/user/olddocs`)

The UnpackZip function selectively unpacks a .tar.gz archive named name into the path directory. The pattern array contains file patterns to be unpacked. The ignore array contains file patterns to skip. The pattern and ignore parameters can be empty arrays. If the pattern begins and ends with /, then it is treated as a regular expression.
arr empty
arr skip = {`/temp.pdf/`, `/.txt$/`}
UnpackZip("/home/user/out/my.tar.gz", `/home/user/tmp`, empty, skip )

The Zip function packs the file or the contents of the path directory into a .zip archive named name.
Zip("/home/user/out/mydoc.zip", `/home/user/docs/important.docx`)
Copy link
On this page
Functions
ArchiveName(finfo fi, str root) str
CloseTarGz(handle h)
CloseZip(handle h)
CreateTarGz(str name) handle
CreateZip(str name) handle
CompressFile(handle h, str fname, str packname)
ReadTarGz(str name) arr.finfo
ReadZip(str name) arr.finfo
TarGz(str name, str path)
UnpackTarGz(str name, str path)
UnpackTarGz(str name, str path, arr pattern, arr ignore)
UnpackZip(str name, str path)
UnpackZip(str name, str path, arr pattern, arr ignore)
Zip(str name, str path)