Zlib v1.0.0 documentation
Documentation generated by XL CLAIRE v3.3.37 at Fri, 17 Nov 2006
- Compression filters
Zlib categories
Compression filters
This module implements compression algorithm as decribed by RFC 1951
(deflate format) and RFC 1950 (gzip format). This module relies on the
popular zlib library. This implementation defines two kind of filter :
Zlib/deflater <: filter Zlib/gziper <: Zlib/deflater
|
That are respectively instanciated by deflater! @ port and gziper! @ port.
As an exemple we could write a fopen like method that handles compressed
files :
gzopen(f:string, mode:{"r", "w"}) : gziper -> let f := fopen(f, mode) in close_target!(Zlib/gziper!(f))
|
Then we would write a compression method that take the name of an input file
and the name of a target compressed file as follow :
compress_file(fin:string, fout:string) : void -> let f := fopen(fin, "r"), gz := gzopen(fout, "w") in (freadwrite(f, gz), fclose(f), fclose(gz))
|
Zlib methods
Zlib/deflater!(self:port) -> deflater
deflater!(self) is equivalent to deflater!(self, 6)
Zlib/deflater!(self:port, compression_level:0 .. 9) -> deflater
deflater!(self, compression_level) creates a new deflate filter
on the port self. compression_level is an integer in the range (0 .. 9)
and drives the compression strategy :
- 1 gives best speed,
- 9 gives best compression,
- 0 gives no compression at all (the input data is simply copied a block at a time)
Zlib/gziper!(self:port) -> gziper
gziper!(self) is equivalent to gziper!(self, 6).
Zlib/gziper!(self:port, compression_level:0 .. 9) -> gziper
gziper!(self, compression_level) is similar to deflater!(self, compression_level)
concerning the compression algorithm (gziper derive from deflater) but also adds a
gzip specific header to the head of the compressed stream and a CRC check sum to the
tail of stream (at close time).
Zlib/zlibversion() -> string
zlibversion() return the version of the underlying zlib library.