通过 miniz 实现平台独立的 zip 压缩
Cross-Platform ‘zip’ Compression
Stable version:
install.packages("zip")Development version:
pak::pak("r-lib/zip")unzip() on URLs.zip_process() and unzip_process(), need
the processx package.library(zip)zip() creates a new ZIP archive. (It overwrites the output file if it
exists.) Simply supply all directories and files that you want to
include in the archive.
It makes sense to change to the top-level directory of the files before archiving them, so that the files are stored using a relative path name.
zip("sources.zip", c("R", "src"))
file.info("sources.zip")
#> size isdir mode mtime ctime
#> sources.zip 603127 FALSE 644 2025-01-07 10:40:54 2025-01-07 10:40:54
#> atime uid gid uname grname
#> sources.zip 2023-11-03 17:09:37 501 20 gaborcsardi staffDirectories are added recursively by default.
zip_append() is similar to zip(), but it appends files to an
existing ZIP archive.
zip_list() lists files in a ZIP archive. It returns a data frame:
…unzip() uncompresses a ZIP archive:
exdir [1] "R" "src"unzip() and zip_list() also work on HTTP(S) URLs, without
downloading the whole file. This needs the curl package to be installed:
…Pass a password argument to encrypt entries with WinZip AES-256 (the
default), which is supported by 7-Zip, WinZip, and macOS Archive
Utility:
…You can use the zip_process() and unzip_process() functions to
create background zip / unzip processes. These processes were
implemented on top of the processx::process class, so they are
pollable.
zip() and unzip() (and co.) support progress bars if the cli
package is installed. This is disabled by default (for now), but can be
enabled by setting the zip_progress option or the ZIP_PROGRESS
environment variable to TRUE.
zip_password: The default password for ZIP encryption and
decryption. Can be set to a string, a raw vector, or a function
returning one.zip_progress: If set to TRUE, progress bars are enabled. Takes
precedence over the ZIP_PROGRESS environment variable.zip_threads: The number of threads to use for threaded operations.
Takes precedence over the ZIP_THREADS environment variable.R_ZIP_PROCESS_FALLBACK: If set to TRUE, unzip_process()
functions will fall back to using an R subprocess, without trying to
use the cmdunzip executable embedded into the package. This is useful
when cmdunzip.exe is blocked by system policies on Windows.ZIP_PROGRESS: If set to TRUE, progress bars are enabled. The
zip_progress option takes precedence over this environment variable.ZIP_THREADS: The number of threads to use for threaded operations.
The zip_threads option takes precedence over this environment
variable.MIT
暂无开放 Issues,或尚未同步最近议题。