Extract contents of an archive to a directory
archive_extract(
archive,
dir = ".",
files = NULL,
options = character(),
strip_components = 0L
)
character(1)
The archive filename or an archive
object.
character(1)
Directory location to extract archive contents, will be created
if it does not exist.
character() || integer() || NULL
One or more files within the archive,
specified either by filename or by position.
character()
default: character(0)
Options to pass to the filter or format.
The list of available options are documented in
options can have one of the following forms:
option=value
The option/value pair will be provided to every module.
Modules that do not accept an option with this name will
ignore it.
option
The option will be provided to every module with a value
of "1".
!option
The option will be provided to every module with a NULL
value.
module:option=value
, module:option
, module:!option
As above, but the corresponding option and value will be
provided only to modules whose name matches module.
See read options for available read options
See write options for available write options
Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped.
The filenames extracted (invisibly).
If files
is NULL
(the default) all files will be extracted.
a <- system.file(package = "archive", "extdata", "data.zip")
d <- tempfile()
# When called with default arguments extracts all files in the archive.
archive_extract(a, d)
list.files(d)
#> [1] "airquality.csv" "iris.csv" "mtcars.csv"
unlink(d)
# Can also specify one or more files to extract
d <- tempfile()
archive_extract(a, d, c("iris.csv", "airquality.csv"))
list.files(d)
#> [1] "airquality.csv" "iris.csv"
unlink(d)