Gzip encoding based on zlib library written by Jean-loup Gailly - http://www.zlib.net/
Depending on the target OS please select the right shared or dynamic library from http://www.zlib.net/.
If the zlib library is not already available on the system you might need to set the full path to the downloaded library in zlib-prototype.p.
// compress a file, overwrite the output file if exists Zlib:getInstance(1000):compressFile('input.txt', 'output.zip', true). // compress string (character or longchar), raise error if the output file exists Zlib:getInstance():compress('uncompressed text', 'text.zip'). // uncompress a file, overwrite the output file if exists Zlib:getInstance(10000):uncompressFile('input.zip', 'logo.png', true).
Copyright © 2014 Marian Edu maria@ganim ede.ro n.edu
Released as open source courtesy of XPower http://www.xpower.be
This software is provided *’as-is’*, without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Zlib | Gzip encoding based on zlib library written by Jean-loup Gailly - http://www.zlib.net/ |
Properties | |
workBufferSize | The default working buffer size. |
Methods | |
getInstance | Static method used to obtain a Zlib compression instance. |
getInstance | Static method used to obtain a Zlib compression instance, it will also set the default working buffer size on it. |
compress | Compresses the data from input string and returns a memory buffer holding compressed data. |
compress | Compresses the data from input memory buffer and returns a new buffer holding compressed data. |
compress | Compresses the data from input memory buffer and save the compressed data in a file using the gzip file format. |
compress | Compresses the data from input memory buffer and save the compressed data in a file using the gzip file format. |
compress | Compresses the data from input string and save the compressed data in a file using the gzip file format. |
compress | Compresses the data from input string and save the compressed data in a file using the gzip file format. |
compressFile | Compresses the data from the input file and save the compressed data in a file using the gzip file format. |
compressFile | Compresses the data from the input file and save the compressed data in a file using the gzip file format. |
uncompress | Uncompresses the data from input memory buffer and return the uncompressed data in a new memory buffer. |
uncompress | Uncompresses the data from input memory buffer and return the uncompressed data in a new memory buffer. |
uncompress | Uncompresses the data from input memory buffer and save the uncompressed data in a file. |
uncompress | Uncompresses the data from input memory buffer and save the uncompressed data in a file. |
uncompressFile | Uncompresses the data from input gzip compressed file and save the uncompressed data in a file. |
uncompressFile | Uncompresses the data from input gzip compressed file and save the uncompressed data in a file. |
define public property workBufferSize as int64
The default working buffer size.
Used by default for in-memory uncompress if destination buffer size is not specified and for file compression/uncompression to process file data in chunks.
Setting this to a lower values will have an important effect on compression/uncompression performance, to high values will lead to a greater memory usage during operations.
Default value is 100k bytes.
method static public Zlib getInstance ( workBufferSize as int64 )
Static method used to obtain a Zlib compression instance, it will also set the default working buffer size on it.
The work buffer size of Zlib compression instance.
A instance of Zlib compression object (singleton).
method public memptr compress ( strData as longchar )
Compresses the data from input string and returns a memory buffer holding compressed data.
The memory location of returning buffer need to be freed by the caller.
The input string (longchar or character) holding the data to be compressed.
A new memory buffer holding the compressed data.
method public memptr compress ( dataBuffer as memptr )
Compresses the data from input memory buffer and returns a new buffer holding compressed data.
The memory location of returning buffer need to be freed by the caller.
The input memory buffer holding the data to be compressed.
A new memory buffer holding the compressed data.
method public int64 compress ( dataBuffer as memptr, gzipPath as character )
Compresses the data from input memory buffer and save the compressed data in a file using the gzip file format.
If the output file exists this method will throw an error.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public int64 compress ( dataBuffer as memptr, gzipPath as character, forceOverwrite as logical )
Compresses the data from input memory buffer and save the compressed data in a file using the gzip file format.
If forceOverwrite flag is set to false and the output file exists this method will throw an error, if set to true the file will be overwriten.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public int64 compress ( strData as longchar, gzipPath as character )
Compresses the data from input string and save the compressed data in a file using the gzip file format.
If the output file exists this method will throw an error.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public int64 compress ( strData as longchar, gzipPath as character, forceOverwrite as logical )
Compresses the data from input string and save the compressed data in a file using the gzip file format.
If forceOverwrite flag is set to false and the output file exists this method will throw an error, if set to true the file will be overwriten.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public int64 compressFile ( filePath as character, gzipPath as character )
Compresses the data from the input file and save the compressed data in a file using the gzip file format.
If the output file exists this method will throw an error.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public int64 compressFile ( filePath as character, gzipPath as character, forceOverwrite as logical )
Compresses the data from the input file and save the compressed data in a file using the gzip file format.
If forceOverwrite flag is set to false and the output file exists this method will throw an error, if set to true the file will be overwriten.
The size of compressed data written in gzip file, only the payload excluding gzip format additional information.
method public memptr uncompress ( dataBuffer as memptr )
Uncompresses the data from input memory buffer and return the uncompressed data in a new memory buffer.
The default workBufferSize is set as the maximum size of uncompressed memory buffer.
If the destination maximum memory size is not large enough the method will raise an error.
The input memory buffer holding the compressed data.
The new memory buffer holding uncompressed data, the caller is responsible of freeing it afterwards.
method public memptr uncompress ( dataBuffer as memptr, bufferSize as int64 )
Uncompresses the data from input memory buffer and return the uncompressed data in a new memory buffer.
If the destination maximum memory size is not large enough the method will raise an error.
The new memory buffer holding uncompressed data, the caller is responsible of freeing it afterwards.
method public int64 uncompress ( dataBuffer as memptr, filePath as character )
Uncompresses the data from input memory buffer and save the uncompressed data in a file. If the output file exists this method will throw an error.
The size of uncompressed data written to output file.
method public int64 uncompress ( dataBuffer as memptr, filePath as character, forceOverwrite as logical )
Uncompresses the data from input memory buffer and save the uncompressed data in a file. If the output file exists this method will throw an error.
The size of uncompressed data written to output file.
method public int64 uncompressFile ( gzipPath as character, filePath as character )
Uncompresses the data from input gzip compressed file and save the uncompressed data in a file. If the output file exists this method will throw an error.
The size of uncompressed data written to output file.
method public int64 uncompressFile ( gzipPath as character, filePath as character, forceOverwrite as logical )
Uncompresses the data from input gzip compressed file and save the uncompressed data in a file. If forceOverwrite flag is set to false and the output file exists this method will throw an error, if set to true the file will be overwriten.
The size of uncompressed data written to output file.