Allows the compression and uncompression of files
Arguments
- infile
the file to be zipped or unzipped
- outfile
the resulting zipped or unzipped file
- buffer_size
the size of the buffer to read in at once, default is 4 times the file.size (max 2Gb).
Details
Functions are
gunzip_file
: uncompresses a gz-archive to raw binary data
-gzip_file
: compresses a raw binary data file to a gz-archive
Examples
gzfile <- system.file("extdata", "ex20101224.TEST_ITCH_50.gz", package = "RITCH")
file <- system.file("extdata", "ex20101224.TEST_ITCH_50", package = "RITCH")
# uncompress file
(outfile <- gunzip_file(gzfile, "tmp"))
#> [1] "tmp"
file.info(outfile)
#> size isdir mode mtime ctime
#> tmp 465048 FALSE 644 2024-01-15 14:22:14 2024-01-15 14:22:14
#> atime uid gid uname grname
#> tmp 2024-01-15 14:22:14 1001 127 runner docker
unlink(outfile)
# compress file
(outfile <- gzip_file(file))
#> [1] "ex20101224.TEST_ITCH_50.gz"
file.info(outfile)
#> size isdir mode mtime
#> ex20101224.TEST_ITCH_50.gz 159965 FALSE 644 2024-01-15 14:22:14
#> ctime atime uid gid
#> ex20101224.TEST_ITCH_50.gz 2024-01-15 14:22:14 2024-01-15 14:22:14 1001 127
#> uname grname
#> ex20101224.TEST_ITCH_50.gz runner docker
unlink(outfile)