百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
Z

zip

> 编程语言
开源

通过 miniz 实现平台独立的 zip 压缩

99 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

通过 miniz 实现平台独立的 zip 压缩

zip

Cross-Platform ‘zip’ Compression

Installation

Stable version:

r
install.packages("zip")

Development version:

r
pak::pak("r-lib/zip")

Optional dependencies

  • For progress bars (see below), the cli package is needed.
  • The curl package is needed for using unzip() on URLs.
  • Background processes, i.e. zip_process() and unzip_process(), need the processx package.

Usage

r
library(zip)

Creating ZIP files

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.

r
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  staff

Directories are added recursively by default.

zip_append() is similar to zip(), but it appends files to an existing ZIP archive.

Listing ZIP files

zip_list() lists files in a ZIP archive. It returns a data frame:

…

Uncompressing ZIP files

unzip() uncompresses a ZIP archive:

r
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:

…

Password-protected archives

Pass a password argument to encrypt entries with WinZip AES-256 (the default), which is supported by 7-Zip, WinZip, and macOS Archive Utility:

…

Compressing and uncompressing in background processes

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.

Progress bars

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.

Configuration

Options

  • 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.

Environment variables

  • 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.

License

MIT

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言