Tar
libraryCreates and extracts `.tar` archives, optionally gzip-compressed, in the project workspace. The archive is compressed with gzip when its name ends with `.tgz`, `.tar.gz` or `.gz` (checked ignoring case), for both creating and extracting; any other name gives a plain tar. Archiving a directory stores it under its own name, and extracting never writes outside the destination directory. Symbolic and hard links are kept as links; other special entries (devices, FIFOs) are skipped.
- Kind Library, a global in every script
- Category Files & Documents
- Functions 2
Functions
create()
Section titled “create()”Tar.create(source: string, destination: string)→self Archives a file or a whole directory into a tar file. A file is stored under its file name; a directory is stored with its own name as the top folder. The archive is replaced if it exists, its missing parent directories are created, and the archive itself is left out when it lies inside the source directory. Use a name ending in `.tar.gz` or `.tgz` for a compressed archive. Throws `Failed to create tar archive` when the source does not exist or the archive cannot be written.
Parameters
-
sourcestring - File or directory to archive, relative to the workspace
-
destinationstring - Archive to create, relative to the workspace; `.tar.gz` or `.tgz` compresses
Returns
Example runs in CI
Fl.write("hello.txt", "hello")Tar.create("hello.txt", "hello.tar")Tar.extract("hello.tar", "untarred")print(Fl.exists("untarred/hello.txt"))extract()
Section titled “extract()”Tar.extract(archive: string, destination: string)→self Extracts a tar archive (gzip-compressed when the name ends in `.tgz`, `.tar.gz` or `.gz`) into a directory, creating the directory when needed. Existing files with the same name are overwritten. An entry whose path would end up outside the destination, or a link pointing outside it, aborts the extraction. Throws `Failed to extract tar archive` when the archive is missing or damaged. A file that is not a tar archive but has a name that does not end in `.gz` may be accepted and extract nothing.
Parameters
-
archivestring - Archive to extract, relative to the workspace
-
destinationstring - Directory to extract into, relative to the workspace
Returns