compressFile

fnvoid compressFile(string inputPath, string outputPath, CompressionOptions opts = CompressionOptions.init, string providerName = null)

Compress a file to another file.

Reads data from the input file, compresses it using the specified compression options, and writes the compressed data to the output file.

This is a convenience function that handles file I/O and streaming internally. For more control over the compression process, use the streaming API directly.

Parameters

inputPathPath to the input file to compress.
outputPathPath to the output file where compressed data will be written.
optsCompression options including format and level. Defaults to CompressionOptions.init if not specified.
providerNameOptional name of the compression provider to use. If null, the highest-priority provider for the format is used.

Throws

CompressionError if no provider is registered for the specified format,

or if a compression error occurs. FileException if the input file cannot be opened or the output file cannot be created.

Examples

---

// Compress a file with default GZIP settings compressFile("data.txt", "data.txt.gz", CompressionOptions(CompressionFormat.GZIP));

// Compress with specific provider and level auto opts = CompressionOptions(CompressionFormat.GZIP); opts.numericLevel = 9; compressFile("data.txt", "data.txt.gz", opts, "ddn-gzip"); ---