gzip

0th

Percentile

Gzip/Gunzip a file

Gzip/Gunzip a file.

Keywords
file, programming
Usage
## S3 method for class 'default':
gzip(filename, destname=sprintf("\%s.gz", filename), temporary=FALSE, skip=FALSE,
  overwrite=FALSE, remove=TRUE, BFR.SIZE=1e+07, ...)
 ## S3 method for class 'default':
gunzip(filename, destname=gsub("[.]gz$", "", filename, ignore.case = TRUE),
  temporary=FALSE, skip=FALSE, overwrite=FALSE, remove=TRUE, BFR.SIZE=1e+07, ...)
Arguments
filename
Pathname of input file.
destname
Pathname of output file.
temporary
If TRUE, the output file is created in a temporary directory.
skip
If TRUE and the output file already exists, the output file is returned as is.
overwrite
If TRUE and the output file already exists, the file is silently overwritting, otherwise an exception is thrown (unless skip is TRU
remove
If TRUE, the input file is removed afterward, otherwise not.
BFR.SIZE
The number of bytes read in each chunk.
...
Not used.
Details

Internally gzfile() (see connections) is used to read (write) chunks to (from) the gzip file. If the process is interrupted before completed, the partially written output file is automatically removed.

Value

  • Returns the pathname of the output file. The number of bytes processed is returned as an attribute. isGzipped() returns a logical.

Aliases
  • gzip.default
  • gzip
  • gunzip
  • gunzip.default
  • isGzipped
Examples
cat(file="foo.txt", "Hello world!")
  print(isGzipped("foo.txt"))
  print(isGzipped("foo.txt.gz"))

  gzip("foo.txt")
  print(file.info("foo.txt.gz"))
  print(isGzipped("foo.txt"))
  print(isGzipped("foo.txt.gz"))

  gunzip("foo.txt.gz")
  print(file.info("foo.txt"))

  file.remove("foo.txt")
Documentation reproduced from package R.utils, version 1.28.4, License: LGPL (>= 2.1)

Community examples

Looks like there are no examples yet.