Extract contents of an archive to a directory
Usage
archive_extract(
archive,
dir = ".",
files = NULL,
options = character(),
strip_components = 0L,
password = NA_character_
)Arguments
- archive
character(1)The archive filename or anarchiveobject.- dir
character(1)Directory location to extract archive contents, will be created if it does not exist.- files
character() || integer() || NULLOne or more files within the archive, specified either by filename or by position.- options
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=valueThe option/value pair will be provided to every module. Modules that do not accept an option with this name will ignore it.optionThe option will be provided to every module with a value of "1".!optionThe option will be provided to every module with a NULL value.module:option=value,module:option,module:!optionAs 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
- strip_components
Remove the specified number of leading path elements. Pathnames with fewer elements will be silently skipped.
- password
character(1)The password to process the archive.
Examples
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)