module Bz: Bzip2 interface
Bz provides a very basic interface to the
Datatypes & exceptions
exception IO_error of
IO_error is raised when there is an error reading or
writing on a compressed channel ; the string argument is the message
reported by the OS.
Data_error is raised when a data integrity error
is detected during decompression.
Unexpected_EOF is raised when an
finishes before the logical end of stream is detected.
When any of these exception is raised, the channel is automatically closed
(but you still have to close the Pervasives channel).
val version :
val open_in :
?small:bool -> ?unused:string -> Pervasives.in_channel -> in_channel
open_in opens a compressed stream that is located on a
small : defaults to
false ; when
true it uses a different
method for decompressing that is slower but uses less memory.
val read :
in_channel -> buf:string -> pos:int -> len:int -> int
len characters in a string buffer.
End_of_file if end of stream was already reached.
Returns number of bytes actually read, (a value less than
means end of stream).
val read_get_unused :
in_channel -> string
If there's some data after the compressed stream that you want to read
from the same
val close_in :
in_channel -> unit
val open_out :
?block:int -> Pervasives.out_channel -> out_channel
open_out creates an
out_channel from a
channel. Once the write operations are finished and the compressed channel
is closed, it is possible to continue writing on the
channel. However, reading back requires special care (cf. above).
block : block size to use for compresion. It is a value between 1
and 9 inclusive. 9 is the default and provides best compression but
takes most memory.
val write :
out_channel -> buf:string -> pos:int -> len:int -> unit
val close_out :
out_channel -> unit
These functions compress & decompress to and from string buffers.
val compress :
?block:int -> string -> pos:int -> len:int -> string
val uncompress :
?small:bool -> string -> pos:int -> len:int -> string