The different between zipr
and zip
is how they handle the relative
paths of the input files.
For zip
(and zip_append
), the root of the archive is supposed to
be the current working directory. The paths of the files are fully kept
in the archive. Absolute paths are also kept. Note that this might result
non-portable archives: some zip tools do not handle zip archives that
contain absolute file names, or file names that start with ..//
or
./
. This behavior is kept for compatibility, and we suggest that you
use zipr
and zipr_append
for new code.
E.g. for the following directory structure:
foo
bar
file1
bar2
file2
foo2
file3
Assuming the current working directory is foo
, the following zip
entries are created by zip
:
zip("x.zip", c("bar/file1", "bar2", "../foo2"))
zip_list("x.zip")$filename
#> bar/file1
#> bar2
#> bar2/file2
#> ../foo2
#> ../foo2/file3
For zipr
(and zipr_append
), each specified file or directory in
files
is created as a top-level entry in the zip archive.
We suggest that you use zip
and zip_append
for new code, as they
don't create non-portable archives. For the same directory structure,
these zip entries are created:
zipr("x.zip", c("bar/file1", "bar2", "../foo2"))
zip_list("x.zip")$filename
#> file1
#> bar2
#> bar2/file2
#> foo2
#> foo2/file3
Because of the potential issues with zip()
and zip_append()
,
they are now soft-deprecated, and their first use in the R session
will trigger a reminder message. To suppress this message, you can
use something like this:
withCallingHandlers(
zip::zip(...),
deprecated = function(e) NULL)