ScummVM API documentation
deflate

Description

API for deflate based operations.

Functions

bool Common::inflateZlib (byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen)
 
bool Common::inflateZlibHeaderless (byte *dst, uint *dstLen, const byte *src, uint srcLen, const byte *dict=nullptr, uint dictLen=0)
 
bool Common::inflateClickteam (byte *dst, uint *dstLen, const byte *src, uint srcLen)
 
SeekableReadStreamCommon::wrapCompressedReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0)
 
SeekableReadStreamCommon::wrapDeflateReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0, const byte *dict=nullptr, uint dictLen=0)
 
SeekableReadStreamCommon::wrapClickteamReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0)
 
WriteStreamCommon::wrapCompressedWriteStream (WriteStream *toBeWrapped)
 

Function Documentation

◆ inflateZlib()

bool Common::inflateZlib ( byte *  dst,
unsigned long *  dstLen,
const byte *  src,
unsigned long  srcLen 
)

Thin wrapper around zlib's uncompress() function. This wrapper makes it possible to uncompress data in engines without being forced to link them against zlib, thus simplifying the build system.

Taken from the zlib manual: Decompresses the src buffer into the dst buffer. srcLen is the byte length of the source buffer. Upon entry, dstLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. Upon exit, dstLen is the actual size of the compressed buffer.

Parameters
dstthe buffer to store into.
dstLena pointer to the size of the destination buffer.
srcthe data to be decompressed.
srcLenthe size of the compressed data.
Returns
true on success (i.e. Z_OK), false otherwise.

◆ inflateZlibHeaderless()

bool Common::inflateZlibHeaderless ( byte *  dst,
uint *  dstLen,
const byte *  src,
uint  srcLen,
const byte *  dict = nullptr,
uint  dictLen = 0 
)

Wrapper around zlib's inflate functions. This function will call the necessary inflate functions to uncompress data compressed with deflate but not with the standard zlib header.

Decompresses the src buffer into the dst buffer. srcLen is the byte length of the source buffer, dstLen is the byte length of the output buffer. It decompress as much data as possible, up to dstLen bytes. If a dictionary is provided through the dict buffer, uses it to initializes the internal decompression dictionary, before the decompression takes place.

Parameters
dstthe buffer to store into.
dstLenthe size of the destination buffer.
srcthe data to be decompressed.
srcLenthe size of the compressed data.
dict(optional) a decompress dictionary.
dictLen(optional) the size of the dictionary. Mandatory if dict is not 0.
Returns
true on success (Z_OK or Z_STREAM_END), false otherwise.

◆ inflateClickteam()

bool Common::inflateClickteam ( byte *  dst,
uint *  dstLen,
const byte *  src,
uint  srcLen 
)

Wrapper around zlib's inflate functions. This function will call the modified inflate functions to uncompress data compressed for Clickteam Installer files.

Decompresses the src buffer into the dst buffer. srcLen is the byte length of the source buffer, dstLen is the byte length of the output buffer. It decompress as much data as possible, up to dstLen bytes.

Parameters
dstthe buffer to store into.
dstLenthe size of the destination buffer.
srcthe data to be decompressed.
srcLenthe size of the compressed data.
Returns
true on success (Z_OK or Z_STREAM_END), false otherwise.

◆ wrapCompressedReadStream()

SeekableReadStream* Common::wrapCompressedReadStream ( SeekableReadStream toBeWrapped,
DisposeAfterUse::Flag  disposeParent = DisposeAfterUse::YES,
uint64  knownSize = 0 
)

Take an arbitrary SeekableReadStream and wrap it in a custom stream which provides transparent on-the-fly decompression. Assumes the data it retrieves from the wrapped stream to be either uncompressed or in gzip format. In the former case, the original stream is returned unmodified (and in particular, not wrapped). In the latter case the stream is returned wrapped, unless there is no ZLIB support, then NULL is returned and the old stream is destroyed.

Certain GZip-formats don't supply an easily readable length, if you still need the length carried along with the stream, and you know the decompressed length at wrap-time, then it can be supplied as knownSize here. knownSize will be ignored if the GZip-stream DOES include a length. The created stream also becomes responsible for freeing the passed stream.

It is safe to call this with a NULL parameter (in this case, NULL is returned).

Parameters
toBeWrappedthe stream to be wrapped (if it is in gzip-format)
knownSizea supplied length of the uncompressed data (if not available directly)

◆ wrapDeflateReadStream()

SeekableReadStream* Common::wrapDeflateReadStream ( SeekableReadStream toBeWrapped,
DisposeAfterUse::Flag  disposeParent = DisposeAfterUse::YES,
uint64  knownSize = 0,
const byte *  dict = nullptr,
uint  dictLen = 0 
)

Take an arbitrary SeekableReadStream and wrap it in a custom stream which provides transparent on-the-fly decompression. Assumes the data it retrieves from the wrapped stream is compressed with deflate algorithm.

It is safe to call this with a NULL parameter (in this case, NULL is returned).

Parameters
toBeWrappedthe stream to be wrapped (if it is in gzip-format)
knownSizea supplied length of the uncompressed data (if not available directly)

◆ wrapClickteamReadStream()

SeekableReadStream* Common::wrapClickteamReadStream ( SeekableReadStream toBeWrapped,
DisposeAfterUse::Flag  disposeParent = DisposeAfterUse::YES,
uint64  knownSize = 0 
)

Take an arbitrary SeekableReadStream and wrap it in a custom stream which provides transparent on-the-fly decompression. Assumes the data it retrieves from the wrapped stream is compressed with the Clickteam deflate variant algorithm. The stream is returned wrapped, unless there is no ZLIB support, then NULL is returned and the old stream is destroyed.

It is safe to call this with a NULL parameter (in this case, NULL is returned).

Parameters
toBeWrappedthe stream to be wrapped (if it is in gzip-format)
knownSizea supplied length of the compressed data (if not available directly)

◆ wrapCompressedWriteStream()

WriteStream* Common::wrapCompressedWriteStream ( WriteStream toBeWrapped)

Take an arbitrary WriteStream and wrap it in a custom stream which provides transparent on-the-fly compression. The compressed data is written in the gzip format, unless ZLIB support has been disabled, in which case the given stream is returned unmodified (and in particular, not wrapped). The created stream also becomes responsible for freeing the passed stream.

It is safe to call this with a NULL parameter (in this case, NULL is returned).