wxGzipInputStream::wxGzipInputStream
wxGzipInputStream::~wxGzipInputStream
wxGzipInputStream::GetDateTime
wxGzipInputStream::GetName
wxGzipInputStream
Contents Up Previous Next

wxGzipInputStream

A stream filter to decompress gzipped data. The gzip format is specified in RFC-1952.

A gzip stream can contain the original filename and timestamp of the compressed data. These fields can be obtained using the GetName() and GetDateTime() accessors.

If the stream turns out not to be a gzip stream (i.e. the signature bytes 0x1f, 0x8b are not found), then the constructor unreads the bytes read and sets the stream state to wxSTREAM_EOF.

So given a possibly gzipped stream 'maybe_gzipped' you can construct a decompressed stream 'decompressed' with something like:

wxGzipInputStream gzip(maybe_gzipped);
wxInputStream *decompressed = &gzip;
if (gzip.Eof())
    decompressed = &maybe_gzipped;

The stream will not read past the end of the gzip data, therefore you can read another gzip entry concatenated by creating another wxGzipInputStream on the same underlying stream.

The stream is not seekable, SeekI() returns wxInvalidOffset. Also GetSize() is not supported, it always returns 0.

Derived from

wxFilterInputStream

Include files

<wx/gzstream.h>

See also

wxGzipOutputStream, wxZlibInputStream, wxInputStream.

Members


wxGzipInputStream::wxGzipInputStream

wxGzipInputStream(wxInputStream& stream, wxMBConv& conv = wxConvFile)

Constructs an object to decompress a gzipped stream.

The constructor reads the gzip header. If the original file name and timestamp are present, then they can be obtained through the GetName() and GetDateTime() accessors.

The filename in the header is stored using an 8-bit character set. In a Unicode build conv is used to translate the filename into Unicode (it has no effect on the stream data). RFC-1952 specifies that the character set should be ISO-8859-1, however the default here is to use wxConvFile which more closely matches the behaviour of the gzip program. In a non-Unicode build conv is ignored.

If the first two bytes are not the gzip signature, then the data is not gzipped after all. The stream state is set to wxSTREAM_EOF, and the two bytes are unread so that the underlying stream can be read directly.


wxGzipInputStream::~wxGzipInputStream

~wxGzipInputStream()

Destructor.


wxGzipInputStream::GetDateTime

wxDateTime GetDateTime() const

Returns the original modification time of gzipped data, as obtained from the gzip header.


wxGzipInputStream::GetName

wxString GetName() const

Returns the original filename of gzipped data, with any directory components removed.