Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Z

zip

> 编程语言
Open source

Platform independent zip compression via miniz

99 stars0 likes2 views
WebsiteGitHub

About

Platform independent zip compression via miniz

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

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