Postprocessing: decompress zip, gz, bz2, tar, Z files and optionally delete the compressed copy
Source:R/postprocess.R
bb_decompress.Rd
Functions for decompressing files after downloading. These functions are not intended to be called directly, but rather are specified as a postprocess
option in bb_source
. bb_unzip
, bb_untar
, bb_gunzip
, bb_bunzip2
, and bb_uncompress
are convenience wrappers around bb_decompress
that specify the method.
Usage
bb_decompress(method, delete = FALSE, ...)
bb_unzip(...)
bb_gunzip(...)
bb_bunzip2(...)
bb_uncompress(...)
bb_untar(...)
Value
list with components status (TRUE
on success), files
(character vector of paths to extracted files), and deleted_files
(character vector of paths of files that were deleted)
Details
Tar files can be compressed (i.e. file extensions .tar, .tgz, .tar.gz, .tar.bz2, or .tar.xz). Support for tar files may depend on your platform (see untar
).
If the data source delivers compressed files, you will most likely want to decompress them after downloading. These functions will do this for you. By default, these do not delete the compressed files after decompressing. The reason for this is so that on the next synchronization run, the local (compressed) copy can be compared to the remote compressed copy, and the download can be skipped if nothing has changed. Deleting local compressed files will save space on your file system, but may result in every file being re-downloaded on every synchronization run.
Examples
if (FALSE) { # \dontrun{
## decompress .zip files after synchronization but keep zip files intact
my_source <- bb_source(..., postprocess = list("bb_unzip"))
## decompress .zip files after synchronization and delete zip files
my_source <- bb_source(..., postprocess = list(list("bb_unzip", delete = TRUE)))
} # }