PrevNextUpHome SophiaFramework UNIVERSE 5.3

18.8. SFXZIPDecoder Class

The SFXZIPDecoder class is used to decompress the DEFLATE compressed data by gzip to be read from the SFBSource or SFBAStream instance or the storage such as SFXFile or SFXTCPSocket.

[Note] Limitation

Data can be read from the SFXZIPDecoder storage, but it cannot be written into this storage. The function to move the read pointer is not supported.

How to use the SFXZIPDecoder class

  1. Create the SFXZIPDecoder instance, i.e., the SFXZIPDecoder storage.
  2. Set the DEFLATE compressed storage, stream, or source to the SFXZIPDecoder storage with the SFXZIPDecoder::Open function.
  3. Get the input stream with the SFXZIPDecoder::GetStreamReader function.
  4. Read data from the SFXZIPDecoder storage using the input stream. At this time, the read data has already been decompressed.
  5. * If the input stream is not used, the decompressed data can be read from the SFXZIPDecoder storage with the SFXZIPDecoder::Read function.
  6. Close the SFXZIPDecoder storage with the SFXZIPDecoder::Close function.

Example 18.11. Initiate

SFXFile file;
SFXZIPDecoder decoder;
SFXAnsiString string;

// open file
file.Open(SFXPath("/testdata.tar.gz"));

// set the specified storage to decoder
// * stream, or source can also be set
decoder.Open(file);

// get input stream for reading data
decoder.GetStreamReader(&reader);

Example 18.12. Terminate

decoder.Close();
file.Close();

Reference: Sample Code