untar(tarfile, files = NULL, list = FALSE, exdir = ".", compressed = NA, extras = NULL, verbose = FALSE, restore_times = TRUE, tar = Sys.getenv("TAR"))
TRUE, list the files (the equivalent of
tar -tf). Otherwise extract the files (the equivalent of
tar -C). It will be created if necessary.
"xz"select that form of compression (and may be abbreviated to the first letter).
TRUEindicates gzip compression,
FALSEno known compression (but an external
tarcommand may detect compression automagically), and
NA(the default) indicates that the type is inferred from the file header.
NULLor a character string: further command-line flags such as -p to be passed to an external
tarcan also contain flags separated from the command by spaces.
list = TRUE, a character vector of (relative or absolute) paths of files contained in the tar archive.Otherwise the return code from
systemwith an external
tarcommand or for an internal implementation written in R. The latter is used if
tarfileis a connection or if the argument
""(except on Windows, when
tar.exeis tried first).
What options are supported will depend on the
Modern GNU flavours of
tar will support compressed archives,
and since 1.15 are able to detect the type of compression
automatically: version 1.20 added support for
version 1.22 for
xz compression using LZMA2. OS X 10.6 and
later (and FreeBSD and some other OSes) have a
bsdtar) from the libarchive project which
can also detect
automatically. For other flavours of
variable R_GZIPCMD gives the command to decompress
compress files, and
verbose are only
used when an external
tar is used.
The internal implementation restores symbolic links as links on a
Unix-alike, and as file copies on Windows (which works only for
existing files, not for directories), and hard links as links. If the
linking operation fails (as it may on a FAT file system), a file copy
is tried. Since it uses
gzfile to read a file it can
handle files compressed by any of the methods that function can
handle: at least
xz compression, and some types of
compression. It does not guard against restoring absolute file paths,
tar implementations do. It will create the parent
directories for directories or files in the archive if necessary. It
handles the standard (USTAR/POSIX), GNU and
pax ways of
handling file paths of more than 100 bytes, and the GNU way of
handling link targets of more than 100 bytes.
You may see warnings from the internal implementation such as
unsupported entry type 'x'This often indicates an invalid archive: entry types
"A-Z"are allowed as extensions, but other types are reserved. The only thing you can do with such an archive is to find a
tarprogram that handles it, and look carefully at the resulting files. There may also be the warning
using pax extended headersThis is indicates that additional information may have been discarded, such as ACLs, encodings ....
The standards only support ASCII filenames (indeed, only alphanumeric
plus period, underscore and hyphen).
untar makes no attempt to
map filenames to those acceptable on the current system, and treats
the filenames in the archive as applicable without any re-encoding in
the current locale.