This module archives and extract files to and from
a tar file. This module supports the
By convention, the name of a tar file is to end in "
Tar files can be created in one operation using function
Alternatively, for more control, use functions
To extract all files from a tar file, use function
To return a list of the files in a tar file,
use function
To convert an error term returned from one of the functions
above to a readable message, use function
If
If
The
An example of this is the SFTP support in
For maximum compatibility, it is safe to archive files with names
up to 100 characters in length. Such tar files can generally be
extracted by any
For filenames exceeding 100 characters in length, the resulting tar
file can only be correctly extracted by a POSIX-compatible
Files with longer names than 256 bytes cannot be stored.
The file name a symbolic link points is always limited to 100 characters.
Adds a file to a tar file that has been opened for writing by
Options:
By default, symbolic links are stored as symbolic links
in the tar file. To override the default and store the file
that the symbolic link points to into the tar file, use
option
Prints an informational message about the added file.
Reads data in parts from the file. This is intended for
memory-limited machines that, for example, builds a tar file
on a remote machine over SFTP, see
Adds a file to a tar file that has been opened for writing by
Closes a tar file
opened by
Creates a tar file and archives the files whose names are specified
in
Creates a tar file and archives the files whose names are specified
in
The options in
The entire tar file is compressed, as if it has
been run through the
By default, function
By default, symbolic links are stored as symbolic links in
the tar file. To override the default and store the file that
the symbolic link points to into the tar file, use
option
Prints an informational message about each added file.
Extracts all files from a tar archive.
If argument
If argument
Otherwise,
Extracts files from a tar archive.
If argument
If argument
Otherwise,
The following options modify the defaults for the extraction as follows:
Files with relative filenames are by default extracted
to the current working directory. With this option, files are
instead extracted into directory
By default, all files are extracted from the tar file. With
this option, only those files are extracted whose names are
included in
With this option, the file is uncompressed while extracting. If the tar file is not compressed, this option is ignored.
By default, function
Instead of extracting to a directory, this option gives the
result as a list of tuples
By default, all existing files with the same name as files in the tar file are overwritten. With this option, existing files are not overwriten.
Prints an informational message for each extracted file.
Cconverts an error reason term to a human-readable error message string.
The
The
Parameter
The following are the fun clauses parameter lists:
Writes term
Closes the access.
Reads using
Sets the position of
Example:
The following is a complete
ExampleFun =
fun(write, {Fd,Data}) -> file:write(Fd, Data);
(position, {Fd,Pos}) -> file:position(Fd, Pos);
(read2, {Fd,Size}) -> file:read(Fd, Size);
(close, Fd) -> file:close(Fd)
end
Here
{ok,Fd} = file:open(Name, ...).
{ok,TarDesc} = erl_tar:init(Fd, [write], ExampleFun),
erl_tar:add(TarDesc, SomeValueIwantToAdd, FileNameInTarFile),
...,
erl_tar:close(TarDesc)
When the
This example with the
The
Creates a tar file for writing (any existing file with the same name is truncated).
By convention, the name of a tar file is to end in "
Except for the
The entire tar file is compressed, as if it has been run
through the
By default, the tar file is opened in
To add one file at the time into an opened tar file, use function
The
Retrieves the names of all files in the tar file
Retrieves the names of all files in the tar file
Prints the names of all files in the tar file
Prints names and information about all files in the tar file