11% File src / library / utils / man / untar.Rd
22% Part of the R package , https : // www.R - project.org
3- % Copyright 2009 - 2019 R Core Team
3+ % Copyright 2009 - 2025 R Core Team
44% Distributed under GPL 2 or later
55
66\name {untar }
@@ -40,13 +40,14 @@ untar(tarfile, files = NULL, list = FALSE, exdir = ".",
4040
4141 \item {compressed }{(Deprecated in favour of auto - detection , used only
4242 for an external \command {tar } command. ) Logical or character
43- string. Values \code {" gzip" }, \code {" bzip2" } and \code {" xz" } select
44- that form of compression (and may be abbreviated to the first
45- letter ). \code {TRUE } indicates \command {gzip } compression ,
46- \code {FALSE } no known compression , and \code {NA } (the default )
47- indicates that the type is to be inferred from the file header.
48-
49- The external command may ignore the selected compression type but
43+ string. Values \code {" gzip" }, \code {" bzip2" }, \code {" xz" } and
44+ \code {" zstd" } select that form of compression (and may be
45+ abbreviated to the first letter ). \code {TRUE } indicates
46+ \command {gzip } compression , \code {FALSE } no known compression , and
47+ \code {NA } (the default ) indicates that the type is to be inferred
48+ from the file header.
49+
50+ The external command may ignore the selected compression type and
5051 detect a type automagically.
5152 }
5253
@@ -85,9 +86,9 @@ untar(tarfile, files = NULL, list = FALSE, exdir = ".",
8586 }
8687
8788 \item {tar }{character string : the path to the command to be used or
88- \code {" internal" }. If the command itself contains spaces it needs
89- to be quoted -- but \code {tar } can also contain flags separated from
90- the command by spaces. }
89+ \code {" internal" } or \ code { " " } . If the command itself contains
90+ spaces it needs to be quoted -- but \code {tar } can also contain
91+ flags separated from the command by spaces. }
9192}
9293
9394\details {
@@ -107,16 +108,24 @@ untar(tarfile, files = NULL, list = FALSE, exdir = ".",
107108 \item {GNU tar : }{Modern GNU \command {tar } versions support
108109 compressed archives and since 1.15 are able to detect the type of
109110 compression automatically : version 1.22 added support for
110- \command {xz } compression.
111+ \command {xz } compression and version 1.31 for \command {zstd }
112+ compression.
111113
112114 On a Unix - alike , \command {configure } will set environment variable
113115 \env {TAR }, preferring GNU tar if found. }
114116
115117 %% bsdtar had it in FreeBSB 5.3 (2004 )
116118 \item {\code {bsdtar }: }{macOS 10.6 and later (and FreeBSD and some
117- other OSes ) have a \command {tar }
118- from the \I {libarchive } project which detects all three forms
119- of compression automagically (even if undocumented in macOS ). }
119+ other OSes ) have a \command {tar } from the \I {libarchive } project
120+ which detects known - to - it forms of compression automagically.
121+ However , this may rely on an external command being available : macOS
122+ has a tar which knows about \code {zstd } compression , but relies
123+ on a \command {zstd } command which it does not supply.
124+
125+ This added support for \command {xz } in 2019 and for \command {zstd }
126+ in 2020 (if the appropriate library or external program is
127+ available ).
128+ }
120129
121130 \item {NetBSD : }{It is undocumented if \I {NetBSD }' s \c ommand{tar} can
122131 detect compression automagically: for versions before 8 the flag
@@ -132,22 +141,23 @@ untar(tarfile, files = NULL, list = FALSE, exdir = ".",
132141
133142 \item {Heirloom Toolchest : }{This \command {tar } does automagically
134143 detect \command {gzip } and \command {bzip2 } compression (undocumented )
135- but has no support for \command {xz } compression. }
144+ but had no support for \command {xz } nor \ command { zstd } compression. }
136145
137146 \item {Older support : }{Environment variable \env {R_GZIPCMD } gives the
138147 command to decompress \command {gzip } files , and
139148 \env {R_BZIPCMD } for \command {bzip2 } files. (On Unix - alikes
140- these are set at installation if found. ) \command {xz } is used if
141- available : if not decompression is expected to fail. }
149+ these are set at installation if found. ) An external program called
150+ \command {xz } or \command {zstd } is used if available : if not
151+ decompression is expected to fail. }
142152 }
143153
144154 Arguments \code {compressed }, \code {extras } and \code {verbose } are only
145155 used when an external \command {tar } is used.
146156
147157 Some external \command {tar } commands will detect some of
148- \command {lrzip }, \command {lzma }, \command {lz4 }, \command {lzop } and
149- \ command { zstd } compression in addition to \command {gzip },
150- \command {bzip2 } and \command {xz }. (For some external \command {tar }
158+ \command {lrzip }, \command {lzma }, \command {lz4 } and \command {lzop }
159+ compression in addition to \command {gzip }, \ command { bzip2 },
160+ \command {xz } and \command {zstd }. (For some external \command {tar }
151161 commands , compressed tarfiles can only be read if the appropriate
152162 utility program is available. ) For GNU \command {tar }, further
153163 (de )compression programs can be specified by e.g. \sspace {}\code {extras
@@ -162,14 +172,14 @@ untar(tarfile, files = NULL, list = FALSE, exdir = ".",
162172 linking operation fails (as it may on a FAT file system ), a file copy
163173 is tried. Since it uses \code {\link {gzfile }} to read a file it can
164174 handle files compressed by any of the methods that function can
165- handle : at least \command {compress }, \command {gzip }, \command {bzip2 }
166- and \command {xz } compression , and some types of \ command { lzma }
167- compression. It does not guard against restoring absolute file paths ,
168- as some \command {tar } implementations do. It will create the parent
169- directories for directories or files in the archive if necessary. It
170- handles the \I {USTAR }/ POSIX , GNU and \ command { pax } ways of handling file
171- paths of more than 100 bytes , and the GNU way of handling link targets
172- of more than 100 bytes.
175+ handle : at least \command {compress }, \command {gzip }, \command {bzip2 },
176+ \ command { xz } and \command {zstd } compression , and some types of
177+ \ command { lzma } compression. It does not guard against restoring
178+ absolute file paths , as some \command {tar } implementations do. It
179+ will create the parent directories for directories or files in the
180+ archive if necessary. It handles the \I {USTAR }/ POSIX , GNU and
181+ \ command { pax } ways of handling file paths of more than 100 bytes , and
182+ the GNU way of handling link targets of more than 100 bytes.
173183
174184 You may see warnings from the internal implementation such
175185 as \preformatted { unsupported entry type ' x' }
0 commit comments