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) |
SeekableReadStream * | Common::wrapCompressedReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0) |
SeekableReadStream * | Common::wrapDeflateReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0, const byte *dict=nullptr, uint dictLen=0) |
SeekableReadStream * | Common::wrapClickteamReadStream (SeekableReadStream *toBeWrapped, DisposeAfterUse::Flag disposeParent=DisposeAfterUse::YES, uint64 knownSize=0) |
WriteStream * | Common::wrapCompressedWriteStream (WriteStream *toBeWrapped) |
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.
dst | the buffer to store into. |
dstLen | a pointer to the size of the destination buffer. |
src | the data to be decompressed. |
srcLen | the size of the compressed data. |
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.
dst | the buffer to store into. |
dstLen | the size of the destination buffer. |
src | the data to be decompressed. |
srcLen | the size of the compressed data. |
dict | (optional) a decompress dictionary. |
dictLen | (optional) the size of the dictionary. Mandatory if dict is not 0. |
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.
dst | the buffer to store into. |
dstLen | the size of the destination buffer. |
src | the data to be decompressed. |
srcLen | the size of the compressed data. |
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).
toBeWrapped | the stream to be wrapped (if it is in gzip-format) |
knownSize | a supplied length of the uncompressed data (if not available directly) |
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).
toBeWrapped | the stream to be wrapped (if it is in gzip-format) |
knownSize | a supplied length of the uncompressed data (if not available directly) |
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).
toBeWrapped | the stream to be wrapped (if it is in gzip-format) |
knownSize | a supplied length of the compressed data (if not available directly) |
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).