[fpc-pascal] TStream descendant to compress/decompress gzip data from another stream

Michalis Kamburelis michalis.kambi at gmail.com
Wed Mar 27 20:13:32 CET 2013


José Mejuto wrote:
> El 27/03/2013 19:22, Michalis Kamburelis escribió:
>
>> Google found an old thread on lazarus mailing list about this ("FPC,
>> gzip and stream") but without any solution, everything mentioned there
>> has either the limitations of TCompressionStream/TDecompressionStream
>> (no gzip format) or TGZFileStream (not able to work wit ObjectPascal
>> streams).
>>
>
> Hello,
>
> .gz is a quite simple format, but it can not be implemented as a TStream
> (only) descendant because in a single .gz file many files could be added
> so something like the class to handle .zip files should be used.

The existing TGZFileStream in ZStream unit already shows that it can be 
implemented, i.e. TGZFileStream reads gzip data and is a TStream 
descendant. I assume that TGZFileStream simply returns the first file 
inside a multi-file gzip (otherwise it would need to call gzopen 
multiple times, as far as I understand).

This is also my use case: I know that my .gz files should contain only 
one file (X3D standard guarantees it for me), I want to ignore the 
remaining files (if any).

>
> Parsing the .gz header is easy, and calling TCompressionStream and
> TDecompressionstream over the payload should be easy, but only for the
> first file in the .gz
>

I will probably have to implement it then. I was hoping to have 
something available ready, since ZStream contains things that are *so* 
close (but not quite) to what I want :)

Thanks,
Michalis



More information about the fpc-pascal mailing list