Version 4 of zlib stream

Updated 2012-09-26 13:30:16 by LkpPo
zlib stream mode ?level?

This command, part of zlib, creates a streaming compression or decompression command, allowing greater control over the compression/decompression process. It returns the name of the stream instance command. The mode must be one of compress, decompress, deflate, inflate, gzip, gunzip. The optional level, which is only valid for compressing streams, gives the compression level from 0 (none) to 9 (max).

The returned streamInst command will support the following subcommands:

streamInst add ?option? data
    • Shortcut for a put followed by a get.
streamInst checksum
    • Returns the current checksum of the uncompressed data, calculated using the appropriate algorithm for the stream's mode.
streamInst close
    • Disposes of the streamInst command. Deleting with rename works the same.
streamInst eof
    • Returns whether the end of the input data has been reached.
streamInst finalize
    • Shortcut for “streamInst put -finalize {}”.
streamInst flush
    • Shortcut for “streamInst put -flush {}”.
streamInst fullflush
    • Shortcut for “streamInst put -fullflush {}”.
streamInst get ?count?
    • Return up to count bytes from the stream's internal buffers. If count is unspecified, return as much as is available (without flushing).
streamInst put ?option? data
    • Appends the bytes data to the stream, compressing or decompressing as necessary. The option controls the type of flush done: -flush means to ensure that all data appended to the stream has been processed and made ready for get at some compression performance penalty, -fullflush also makes sure that the compression engine can restart from the point after the flush (at more penalty), and -finalize states that no more data will be written to the stream, causing any trailing bytes required by the format to be written.
streamInst reset
    • Recreates the stream, ready to start afresh. Discards whatever is in the stream's buffers.