% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/zip.R
\name{unzip}
\alias{unzip}
\title{Uncompress 'zip' Archives}
\usage{
unzip(
  zipfile,
  files = NULL,
  overwrite = TRUE,
  junkpaths = FALSE,
  exdir = ".",
  encoding = NULL,
  password = NULL
)
}
\arguments{
\item{zipfile}{Path to the zip file to uncompress, or a character vector of
paths. When multiple paths are given and all other arguments are at their
defaults, the files are unzipped concurrently in a thread pool.
Set the \code{zip_threads} option or the \code{ZIP_THREADS} environment variable
to control the number of threads used. If neither is set, the \code{Ncpus}
option is used, if set. By default zip uses two threads.}

\item{files}{Character vector of files to extract from the archive.
Files within directories can be specified, but they must use a forward
slash as path separator, as this is what zip files use internally.
If \code{NULL}, all files will be extracted.}

\item{overwrite}{Whether to overwrite existing files. If \code{FALSE} and
a file already exists, then an error is thrown.}

\item{junkpaths}{Whether to ignore all directory paths when creating
files. If \code{TRUE}, all files will be created in \code{exdir}.}

\item{exdir}{Directory to uncompress the archive to. If it does not
exist, it will be created.}

\item{encoding}{Encoding to use for entry filenames. ZIP files signal
UTF-8 filenames via a flag in each entry; those are always decoded as
UTF-8 regardless of \code{encoding}. For entries without that flag, \code{encoding}
is used; \code{NULL} (the default) falls back to IBM CP437, which is what the
ZIP specification prescribes for legacy entries. The value is passed
to \code{\link[=iconv]{iconv()}}.}

\item{password}{Password for decrypting encrypted entries. It can be a
string, a raw vector, or a function that returns one of these. If \code{NULL}
(the default), the \code{zip_password} option is used, or no password if that
is also \code{NULL}. The password is silently ignored for entries that are not
encrypted.}
}
\value{
A data frame with one row per extracted entry and columns,
invisibly: \code{filename} (path within the archive), \code{compressed_size},
\code{uncompressed_size}, \code{timestamp}, \code{permissions}, \code{crc32}, \code{offset},
\code{type} (same as in \code{\link[=zip_list]{zip_list()}}), and \code{path} (absolute path to the
extracted file on disk).
}
\description{
\code{unzip()} always restores modification times of the extracted files and
directories.
}
\section{Permissions}{


If the zip archive stores permissions and was created on Unix,
the permissions will be restored.
}

\examples{
## temporary directory, to avoid messing up the user's workspace.
dir.create(tmp <- tempfile())
dir.create(file.path(tmp, "mydir"))
cat("first file", file = file.path(tmp, "mydir", "file1"))
cat("second file", file = file.path(tmp, "mydir", "file2"))

zipfile <- tempfile(fileext = ".zip")
zip::zip(zipfile, "mydir", root = tmp)

## List contents
zip_list(zipfile)

## Extract and inspect result
tmp2 <- tempfile()
result <- unzip(zipfile, exdir = tmp2)
result[, c("filename", "path")]
}
\seealso{
Other zip/unzip functions:
\code{\link[=zip_list]{zip_list()}}
}
\concept{zip/unzip functions}
