dreamworkAPI
Ctrl K
GitHub
libraryDocs / gzip

gzip

librarysharedmenusource

gzip is a file format that wraps a DEFLATE stream with a header (file name, comment, time) and a CRC-32 checksum with the size of the original data.

Produces and consumes gzip streams compatible with the gzip tool, Content-Encoding: gzip and zlib's gzopen / inflateInit2.

Classes & types

Functions

gzip.compressCompresses a string into a gzip stream.
gzip.decompressDecompresses a gzip stream.

#gzip.compress

sharedmenunodiscardsource
function gzip.compress(raw_data: string, options?: gzip.Options): string

Compresses a string into a gzip stream.

Parameters
NameTypeDescription
raw_datastringThe string to compress.
optionsoptionalgzip.OptionsThe compression options.
Returns
TypeNameDescription
stringcompressed_dataThe compressed string.

#gzip.decompress

sharedmenunodiscardsource
function gzip.decompress(compressed_data: string, start_position?: integer): string, integer, gzip.Header

Decompresses a gzip stream.

Concatenated gzip members are decompressed into one string, like the gzip tool does, data after the last member that is not another gzip member is left unread.

Throws an error on malformed or truncated data, or if the checksum or the size does not match; call via pcall() when processing untrusted input.

Parameters
NameTypeDescription
compressed_datastringThe gzip stream to decompress.
start_positionoptionalintegerThe position of the stream in the string, 1 by default.
Returns
TypeNameDescription
stringdecompressed_dataThe decompressed string.
integerend_positionThe position of the first byte after the stream.
gzip.HeaderheaderThe header of the first member.
Generated from the dreamwork meta branch.