CkGzip C++ Class Reference

CkGzip

GZip compression component.

Properties

void get_Comment(CkString &str);
void put_Comment(const char *str);

Specifies an optional comment string that can be embedded within the .gz when any Compress* method is called.

void get_DebugLogFilePath(CkString &str);
void put_DebugLogFilePath(const char *newVal);

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information. This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are: (1) a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired, (2) the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or (3) there is an internal problem (bug) in the Chilkat code that causes the hang.

void get_ExtraData(CkByteData &data);
void put_ExtraData(const CkByteData &data);

Optional extra-data that can be included within a .gz when a Compress* method is called.

void get_Filename(CkString &str);
void put_Filename(const char *str);

The filename that is embedded within the .gz during any Compress* method call. When extracting from a .gz using applications such as WinZip, this will be the filename that is created.

void LastErrorHtml(CkString &str);

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

void LastErrorText(CkString &str);

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

Concept of LastErrorText

LastErrorText Standard Information

void LastErrorXml(CkString &str);

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

void get_LastMod(SYSTEMTIME &outSysTime);
void put_LastMod(SYSTEMTIME &sysTime);

The last-modification date/time to be embedded within the .gz when a Compress* method is called. By default, the current system date/time is used.

void get_LastModStr(CkString &str);
void put_LastModStr(const char *newVal);

To be documented soon...

bool get_UseCurrentDate(void);
void put_UseCurrentDate(bool newVal);

If set to true, the file produced by an Uncompress* method will use the current date/time for the last-modification date instead of the date/time found within the Gzip format.

bool get_Utf8(void) const;
void put_Utf8(bool b);

When set to true, all "const char *" arguments are interpreted as utf-8 strings. If set to false (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to true, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to false, all "const char *" return values are ANSI strings.

More about the Utf8 Property

C++ CkString Examples

Non-English String Literals in C++ Source Code

bool get_VerboseLogging(void);
void put_VerboseLogging(bool b);

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

void get_Version(CkString &str);

Version of the component, such as "1.0.0"

Methods

bool CompressFile(const char *inFilename, const char * outGzipFilename);

Compresses a file to create a GZip compressed file (.gz).

Returns true for success, false for failure.

bool CompressFile2(const char *inFilename, const char * embeddedFilename, const char * outGzipFilename);

Compresses a file to create a GZip compressed file (.gz). inFilename is the actual filename on disk. embeddedFilename is the filename to be embedded in the .gz such that when it is un-gzipped, this is the name of the file that will be created.

Returns true for success, false for failure.

bool CompressFileToMem(const char *srcPath, CkByteData &outData);

Gzip compresses a file to an in-memory image of a .gz file.

Returns false on failure.

bool CompressMemToFile(const CkByteData &db, const char *destPath);

Gzip compresses and creates a .gz file from in-memory data.

Returns true for success, false for failure.

bool CompressMemory(const CkByteData &dbIn, CkByteData &outData);

Compresses in-memory data to an in-memory image of a .gz file.

bool CompressString(const char *inString, const char * outCharset, CkByteData &outBytes);

Gzip compresses a string and writes the output to a byte array. The string is first converted to the charset specified by outCharset. Typical charsets are "utf-8", "iso-8859-1", "shift_JIS", etc.

Full List of Charset Names

bool CompressStringENC(const char *strIn, const char *charset, const char *encoding, CkString &outStr);

To be documented soon...

bool CompressStringToFile(const char *inStr, const char *destCharset, const char *destPath);

Gzip compresses a string and writes the output to a .gz compressed file. The string is first converted to the charset specified by ARG2. Typical charsets are "utf-8", "iso-8859-1", "shift_JIS", etc.

Returns true for success, false for failure.

Full List of Charset Names

bool Decode(const char *encodedStr, const char * encoding, CkByteData &outBytes);

Decodes an encoded string and returns the original data. The encoding mode is determined by encoding. It may be "base64", "hex", "quoted-printable", or "url".

bool DeflateStringENC(const char *inString, const char * charsetName, const char * outputEncoding, CkString &outStr);

Provides the ability to use the zip/gzip's deflate algorithm directly to compress a string. Internal to this method, inString is first converted to the charset specified by charsetName. The data is then compressed using the deflate compression algorithm. The binary output is then encoded according to outputEncoding. Possible values for outputEncoding are "hex", "base64", "url", and "quoted-printable".

Note: The output of this method is compressed data with no Gzip file format. Use the Compress* methods to produce Gzip file format output.

Returns true for success, false for failure.

Full List of Charset Names

bool Encode(const CkByteData &byteData, const char * encoding, CkString &outStr);

Encodes binary data to a printable string. The encoding mode is determined by encoding. It may be "base64", "hex", "quoted-printable", or "url".

Returns true for success, false for failure.

bool ExamineFile(const char *inGzFilename);

Determines if the inGzFilename is a Gzip formatted file. Returns true if it is a Gzip formatted file, otherwise returns false.

bool ExamineMemory(const CkByteData &inGzData);

Determines if the in-memory bytes (inGzData) contain a Gzip formatted file. Returns true if it is Gzip format, otherwise returns false.

CkDateTime *GetDt();

Gets the last-modification date/time to be embedded within the .gz.

bool InflateStringENC(const char *inString, const char * convertFromCharset, const char * inputEncoding, CkString &outStr);

This the reverse of DeflateStringENC.

The input string is first decoded according to inputEncoding. (Possible values for inputEncoding are "hex", "base64", "url", and "quoted-printable".) The compressed data is then inflated, and the result is then converted from convertFromCharset (if necessary) to return a string.

Returns true for success, false for failure.

bool IsUnlocked();

Returns true if the component has been unlocked.

bool ReadFile(const char *path, CkByteData &outBytes);

Reads a binary file into memory and returns the byte array. Note: This method does not parse a Gzip, it is only a convenience method for reading a binary file into memory.

bool SaveLastError(const char *path);

Saves the last-error information (the contents of LastErrorXml) to an XML formatted file.

bool SetDt(CkDateTime &dt);

Sets the last-modification date/time to be embedded within the .gz when a Compress* method is called. If not explicitly set, the current system date/time is used.

bool UnTarGz(const char *tgzFilename, const char * destDir, bool bNoAbsolute);

Unpacks a .tar.gz file. The ungzip and untar occur in streaming mode. There are no temporary files and the memory footprint is constant (and small) while untarring. bNoAbsolute may be true or false. A value of true protects from untarring to absolute paths. (For example, imagine the trouble if the tar contains files with absolute paths beginning with /Windows/system32)

Returns true for success, false for failure.

bool UncompressFile(const char *srcPath, const char *destPath);

Un-Gzips a .gz file. The output filename is specified by the 2nd argument and not by the filename embedded within the .gz.

Returns true for success, false for failure.

bool UncompressFileToMem(const char *srcPath, CkByteData &outData);

Un-Gzips a .gz file directly to memory.

Returns false on failure.

bool UncompressFileToString(const char *gzFilename, const char * charset, CkString &outStr);

Uncompresses a .gz file that contains a text file. The contents of the text file are returned as a string. The character encoding of the text file is specified by charset. Typical charsets are "iso-8859-1", "utf-8", "windows-1252", "shift_JIS", "big5", etc.

Returns true for success, false for failure.

List of Valid Charsets

bool UncompressMemToFile(const CkByteData &db, const char *destPath);

Un-Gzips from an in-memory image of a .gz file to a file.

Returns true for success, false for failure.

bool UncompressMemory(const CkByteData &dbIn, CkByteData &outData);

Un-Gzips from an in-memory image of a .gz file directly into memory.

Returns false on failure.

bool UncompressString(const CkByteData &inData, const char * inCharset, CkString &outStr);

The reverse of CompressString.

The bytes in inData are uncompressed, then converted from inCharset (if necessary) to return a string.

Returns true for success, false for failure.

Full List of Charset Names

bool UncompressStringENC(const char *strIn, const char *charset, const char *encoding, CkString &outStr);

To be documented soon...

bool UnlockComponent(const char *unlockCode);

Unlocks the component allowing for the full functionality to be used.

Returns true for success, false for failure.

Diagnosing UnlockComponent Problems

UnlockComponent LastErrorText shows exact string passed to it.

Verify UnlockComponent Success w/ Permanent Unlock Code

LastErrorText Standard Information

bool WriteFile(const char *path, const CkByteData &binaryData);

A convenience method for writing a binary byte array to a file.

Returns true for success, false for failure.

bool XfdlToXml(const char *xfldData, CkString &outStr);

Converts base64-gzip .xfdl data to a decompressed XML string. The xfldData contains the base64 data. This method returns the decoded/decompressed XML string.

Returns true for success, false for failure.

const char *comment();

Specifies an optional comment string that can be embedded within the .gz when any Compress* method is called.

Returns a null on failure

const char *compressStringENC(const char *strIn, const char *charset, const char *encoding);

To be documented soon...

const char *debugLogFilePath();

To be documented soon...

const char *deflateStringENC(const char *inString, const char * charsetName, const char * outputEncoding);

Provides the ability to use the zip/gzip's deflate algorithm directly to compress a string. Internal to this method, inString is first converted to the charset specified by charsetName. The data is then compressed using the deflate compression algorithm. The binary output is then encoded according to outputEncoding. Possible values for outputEncoding are "hex", "base64", "url", and "quoted-printable".

Note: The output of this method is compressed data with no Gzip file format. Use the Compress* methods to produce Gzip file format output.

Returns a null on failure

Full List of Charset Names

const char *encode(const CkByteData &byteData, const char * encoding);

Encodes binary data to a printable string. The encoding mode is determined by encoding. It may be "base64", "hex", "quoted-printable", or "url".

Returns a null on failure

const char *filename();

The filename that is embedded within the .gz during any Compress* method call. When extracting from a .gz using applications such as WinZip, this will be the filename that is created.

Returns a null on failure

const char *inflateStringENC(const char *inString, const char * convertFromCharset, const char * inputEncoding);

This the reverse of DeflateStringENC.

The input string is first decoded according to inputEncoding. (Possible values for inputEncoding are "hex", "base64", "url", and "quoted-printable".) The compressed data is then inflated, and the result is then converted from convertFromCharset (if necessary) to return a string.

Returns a null on failure

const char *lastErrorHtml();

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

const char *lastErrorText();

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

Concept of LastErrorText

LastErrorText Standard Information

const char *lastErrorXml();

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

const char *lastModStr();

To be documented soon...

const char *uncompressFileToString(const char *gzFilename, const char * charset);

Uncompresses a .gz file that contains a text file. The contents of the text file are returned as a string. The character encoding of the text file is specified by charset. Typical charsets are "iso-8859-1", "utf-8", "windows-1252", "shift_JIS", "big5", etc.

Returns a null on failure

List of Valid Charsets

const char *uncompressString(const CkByteData &inData, const char * inCharset);

The reverse of CompressString.

The bytes in inData are uncompressed, then converted from inCharset (if necessary) to return a string.

Returns a null on failure

Full List of Charset Names

const char *uncompressStringENC(const char *strIn, const char *charset, const char *encoding);

To be documented soon...

const char *version();

Version of the component, such as "1.0.0"

Returns a null on failure

const char *xfdlToXml(const char *xfldData);

Converts base64-gzip .xfdl data to a decompressed XML string. The xfldData contains the base64 data. This method returns the decoded/decompressed XML string.

Returns a null on failure