Go to the first, previous, next, last section, table of contents.


The Bz module

type in_channel
type out_channel
exception IO_error of string
exception Data_error
exception Unexpected_EOF

Input functions

open_in opens a compressed stream that is located on a Pervasives channel. The optional argument small has value false by default ; when true it uses a different method for decompressing that is slower but uses less memory. When reading is finished on the Bz in_channel, it is not safe to continue reading on the underlying Pervasives channel because the file won't be positioned properly.

external open_in : ?small:bool -> Pervasives.in_channel -> in_channel 
  = "wrap_readopen"

read reads len characters in a string buffer. Returns the number of bytes actually read, 0 when at end of stream.

external read : in_channel -> buf:string -> pos:int -> len:int -> int
  = "wrap_read"

external close_in : in_channel -> unit
  = "wrap_readclose"

Output funcions

open_out creates an out_channel from a Pervasives channel. Once the write operations are finished and the compressed channel is closed, it is possible to continue writing on the Pervasives channel. However, reading back is not really possible (cf. above). The optional block argument specifies the block size to be used for compresion. It is a value between 1 and 9 inclusive. 9 is the default and provides best compression but takes most memory.

external open_out : ?block:int -> Pervasives.out_channel -> out_channel
  = "wrap_writeopen"

external write : out_channel -> buf:string -> pos:int -> len:int -> unit
  = "wrap_write"
external close_out : out_channel -> unit
  = "wrap_writeclose"


Go to the first, previous, next, last section, table of contents.