Cross-Platform 'zip' Compression

Cross-Platform 'zip' Compression Library. A replacement for the 'zip' function, that does not require any additional external tools on any platform.


Linux BuildStatus Windows Buildstatus CRAN RStudio mirrordownloads CoverageStatus

Installation

install.packages("zip")

Usage

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.

zip("sources.zip", c("R", "src"))
file.info("sources.zip")
#>              size isdir mode               mtime               ctime
#> sources.zip 87851 FALSE  644 2019-02-23 22:02:36 2019-02-23 22:02:36
#>                           atime uid gid       uname grname
#> sources.zip 2019-02-23 22:02:36 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:

zip_list("sources.zip")
#>                filename compressed_size uncompressed_size
#> 1                    R/               0                 0
#> 2        R/assertions.R             125               296
#> 3           R/process.R            1383              4471
#> 4             R/utils.R             905              3047
#> 5               R/zip.R            2194              6763
#> 6                  src/               0                 0
#> 7            src/init.c             335               762
#> 8    src/install.libs.R             271               576
#> 9          src/Makevars             185               465
#> 10     src/Makevars.win             188               491
#> 11          src/miniz.c           55232            314589
#> 12          src/miniz.h           18113             66863
#> 13           src/rzip.c            2092              6344
#> 14           src/tools/               0                 0
#> 15 src/tools/cmdunzip.c             214               323
#> 16   src/tools/cmdzip.c             909              2599
#> 17            src/zip.c            3169             11295
#> 18            src/zip.h             504              1211
#>              timestamp permissions
#> 1  2019-02-23 22:00:10         755
#> 2  2019-02-22 22:11:46         644
#> 3  2019-02-23 22:00:10         644
#> 4  2019-02-22 22:27:58         644
#> 5  2019-02-23 20:35:36         644
#> 6  2019-02-23 22:02:32         755
#> 7  2019-02-22 22:11:46         644
#> 8  2019-02-23 20:35:36         644
#> 9  2019-02-23 20:35:36         644
#> 10 2019-02-23 20:35:36         644
#> 11 2019-02-23 01:38:12         755
#> 12 2019-02-22 22:11:46         644
#> 13 2019-02-23 20:35:36         644
#> 14 2019-02-23 22:02:32         755
#> 15 2019-02-23 20:35:36         644
#> 16 2019-02-23 20:35:36         644
#> 17 2019-02-23 20:35:36         644
#> 18 2019-02-23 20:35:36         644

Uncompressing ZIP files

unzip() uncompresses a ZIP archive:

exdir <- tempfile()
unzip("sources.zip", exdir = exdir)
dir(exdir)
#> [1] "R"   "src"

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.

License

CC0

News

2.0.2

  • zip_process() and unzip_process() can now pass extra arguments to processx::process (#32).

  • unzip_process() now makes sure the exdir path is created with forward slashes on Windows, mixing forward and backward slashes can cause errors.

2.0.1

  • zip() and zip_append() are now soft-deprecated, please use zipr() and zipr_append() instead.

2.0.0

  • New zipr() and zipr_append(), they always store relative file names in the archive.

  • New unzip() function for uncompressing zip archives.

  • New zip_process() and unzip_process() functions to create or uncompress an archive in a background process.

  • zip(), zipr(), zip_append() and zipr_append() all include directories in the archives, empty ones as well.

  • zip(), zipr(), zip_append() and zipr_append() all add time stamps to the archive and zip_list() returns then in the timestamp column.

  • zip(), zipr(), zip_append() and zipr_append() all add file and directory permissions to the archive on Unix systems, and zip_list() returns them in the permissions column.

  • zip_list() now correctly reports the size of large files in the archive.

  • Use miniz 2.0.8 internally.

1.0.0

First public release.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("zip")

2.0.2 by Gábor Csárdi, 8 days ago


https://github.com/r-lib/zip#readme


Report a bug at https://github.com/r-lib/zip/issues


Browse source code at https://github.com/cran/zip


Authors: Gábor Csárdi , Kuba Podgórski , Rich Geldreich


Documentation:   PDF Manual  


CC0 license


Suggests covr, processx, R6, testthat, withr


Imported by UCSCXenaShiny, discoveR, googleCloudStorageR, officer, opencpu, openxlsx, predictoR, tidytransit, trread, wallace.

Suggested by cranlike, rotor.


See at CRAN