Home

Awesome

tar

Pure Blade library for creating and extracting TAR archives.

Package Information


Installation


You can install the tar library with Nyssa package manager

nyssa install tar

Important

The library exports two helper function compress() and extract() by that allows you to create and/or extract TAR archives. Note that this library does not yet support TAR archives compressed with the bzip2 algorithm (typically files ending in .bz2 and .tbz).

This library supports the most popular extensions such as .tar.gz, .tar, .gz, and .tgz.

Extracting TAR archives


Use the helper function extract() for a quick way to extract TAR archives.

import tar

tar.extract('/path/to/archive.tar.gz', '/destination')

The destination can be omitted in which case the archive will be extracted into the same directory as the source with same name without the last extension. e.g. for /path/to/file.tar.gz will extract to /path/to/file.tar directory is the destination is not given.

See below for learn more about the extract() method

Creating a new TAR ball


To quickly create a new tarball, you can use the compress() helper function in the library like this,

import tar

tar.compress('/path/to/file/or/directory', '/destination.tar.gz')

The compress function can be used to compress a single file or an entire directory. Like the extract() function, you can choose to omit the destination parameter in which case compress will save the file to the current working directory with the same name as the file/directory with the extension .tar.gz.

See below for learn more about the compress() method

API Definition


For a more fine grained control and to create TAR archives from scratch while adding file and data as you wish or to get the list of files in a TAR archive, you need to make use of the library API as described below. They are self explanatory and you can check out the examples to see more details on their use.

Constants

Functions

Class Tar

Creates or extracts TAR archives with long pathnames (> 100 characters) support in POSIX ustar and GNU longlink formats.

Methods