[fpc-pascal] GZip - Stream decompress only in memory

Michalis Kamburelis michalis.kambi at gmail.com
Mon Sep 5 01:11:53 CEST 2016


 2016-09-04 18:08 GMT+02:00 Marcos Douglas <md at delfire.net>:
> I have streams compressed using GZip. I get these streams from WebServices.
> So, how can I decompress these streams only in memory?

It seems you already have a solution, but here's another one:)

In Castle Game Engine, I have a unit CastleZStream that provides
TGZFileStream that can compress/decompress in memory. It uses the
CastleGzioInternal unit, which is a modified version of Gzio unit from
FPC, modified to be able to work with TStream (not just a file). You
can take these two files to have it working:

https://github.com/castle-engine/castle-engine/blob/master/src/base/castlegziointernal.pas
https://github.com/castle-engine/castle-engine/blob/master/src/base/castlezstream.pas

For base64, the TBase64EncodingStream and TBase64DecodingStream from
standard FPC Base64 unit do the job nicely:)

They all (TBase64EncodingStream, TBase64DecodingStream, TGZFileStream)
descend from TOwnerStream which is a common useful class for a stream
that processes another stream.

Regards,
Michalis



More information about the fpc-pascal mailing list