Module GZip


module GZip: Libs.GZip
GZip - compression/decompression interface.

This module provide access to GZip compression and decompression functionalities. Both the common (de)compression interface (implemented by all compression libraries available via Batteries) and GZip-specific functionalities are accessible using this module.
Author(s): Stefano Zacchiroli



Common decompression interface

val uncompress : IO.input -> IO.input
Wrap an input channel, decompressing transparently data when reading from it.

Operations performed on the returned channel can raise, in addition to their usual exceptions, Codec.Compression_error.

val open_in : ?mode:File.open_in_flag list ->
?perm:File.permission -> string -> IO.input
Shorthand: directly open a compressed file to read from it See File.open_in
val with_in : IO.input -> (IO.input -> 'a) -> 'a
with_in input f creates a new input input' which will transparently decompress data from input, then invokes f input' to process that new input. Once f has returned or triggered an exception, the input' is closed before proceeding.

Common compression interface

val compress : 'a IO.output -> unit IO.output
Wrap an output channel, compressing transparently data when writing to it.

Operations performed on the returned channel can raise, in addition to their usual exceptions, Codec.Compression_error.

If you use this function, you will need to close the channel manually, using IO.close_in.

val open_out : ?mode:File.open_out_flag list ->
?perm:File.permission -> string -> unit IO.output
Shorthand: directly open a compressed file to write to it. See File.open_out
val with_out : unit IO.output -> (unit IO.output -> 'a) -> 'a
with_out output f first creates a new output output' which will transparently compress data to output and then invokes f output'.

Once f output' has returned or triggered an exception, output' is closed before proceeding.


GZip-specific features

Provide acces to GZip-specific features.

val gzip_compress : ?level:int -> 'a IO.output -> unit IO.output
gzip-specific compression function, same as GZip.compress, but enable to specifiy gzip-specific compression parameters
Raises Invalid_argument if level is not included in the expected range
level : compression level (an integer between 1 and 9), with 1 being the weakest (but fastest) compression and 9 being the strongest (but slowest) compression. Default: 6.