Description Usage Arguments Value Permissions Examples
zip_extract()
always restores modification times of the extracted files and
directories.
1 2 3 4 5 6 7 | zip_extract(
zipfile,
files = NULL,
overwrite = TRUE,
junk_paths = FALSE,
exdir = "."
)
|
zipfile |
Path to the zip file to uncompress. |
files |
Character vector of files to extract from the archive.
Files within directories can be specified, but they must use a forward
slash as path separator, as this is what zip files use internally.
If |
overwrite |
Whether to overwrite existing files. If |
junk_paths |
Whether to ignore all directory paths when creating
files. If |
exdir |
Directory to uncompress the archive to. If it does not exist, it will be created. |
An fs::fs_path()
character vecttor of extracted files, invisibly.
This is like the "internal" method of utils::unzip()
and unlike
zip::unzip()
(See r-lib/zip#35). The zip_info()
C internal is called
separately to get file names, which are not yet returned from the C internal
used for extraction.
If the zip archive stores permissions and was created on Unix, the permissions will be restored.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(fs)
dir_create("mydir")
cat("first file", file = path("mydir", "file1"))
cat("second file", file = path("mydir", "file2"))
z <- file_temp(ext = "zip")
zip_create("mydir", z)
## List contents
zip_info(z)
## Extract
tmp <- path_temp()
out <- zip_extract(z, exdir = tmp)
length(out)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.