|
| 1 | +#' Zstd file compression |
| 2 | +#' |
| 3 | +#' A utility function to compresses a file with zstd. |
| 4 | +#' |
| 5 | +#' @usage zstd_compress_file(input_file, output_file, compress_level = qopt("compress_level")) |
| 6 | +#' |
| 7 | +#' @param input_file Path to the file to compress. |
| 8 | +#' @param output_file Path for the compressed file. |
| 9 | +#' @param compress_level The compression level used. |
| 10 | +#' |
| 11 | +#' @return No value is returned. The file is written to disk. |
| 12 | +#' @export |
| 13 | +#' @name zstd_compress_file |
| 14 | +#' |
| 15 | +#' @examples |
| 16 | +#' infile <- tempfile() |
| 17 | +#' writeBin(as.raw(1:5), infile) |
| 18 | +#' outfile <- tempfile() |
| 19 | +#' zstd_compress_file(infile, outfile, compress_level = 1) |
| 20 | +#' stopifnot(file.exists(outfile)) |
| 21 | +NULL |
| 22 | + |
| 23 | +#' Zstd file decompression |
| 24 | +#' |
| 25 | +#' A utility function to decompresses a zstd file to disk. |
| 26 | +#' |
| 27 | +#' @usage zstd_decompress_file(input_file, output_file) |
| 28 | +#' |
| 29 | +#' @param input_file Path to the zstd file. |
| 30 | +#' @param output_file Path for the decompressed file. |
| 31 | +#' |
| 32 | +#' @return No value is returned. The file is written to disk. |
| 33 | +#' @export |
| 34 | +#' @name zstd_decompress_file |
| 35 | +#' |
| 36 | +#' @examples |
| 37 | +#' infile <- tempfile() |
| 38 | +#' writeBin(as.raw(1:5), infile) |
| 39 | +#' zfile <- tempfile() |
| 40 | +#' zstd_compress_file(infile, zfile, compress_level = 1) |
| 41 | +#' outfile <- tempfile() |
| 42 | +#' zstd_decompress_file(zfile, outfile) |
| 43 | +#' stopifnot(identical(readBin(infile, what = "raw", n = 5), readBin(outfile, what = "raw", n = 5))) |
| 44 | +NULL |
0 commit comments