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

Ewald ewald at yellowcouch.org
Thu Mar 28 01:06:06 CET 2013


On 27 Mar 2013, at 19:54, 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.

Sorry to just drop in on this quite late, but isn't gzip  a compression algorithm and not a file format as such? gzip (the command line utility) only compresses one file and *doesn't* put this in a multi-file container. To get `multi-file gzips`, you will first want to bundle the files and compress this bundle (files -> tar -> gzip) or compress the files separately and then bundle them together (files -> multiple separate gzipped files -> tar). Or are we talking about a different gzip here? 

So basically (to answer to the subject of this mail), you will only need a stream that implements this algorithm, which you could quite easily write yourself. Take a look at zlibar, it's a project that iirc implements an archive format that uses gzip. Now there are two functions in there that compress and respectively decompress a stream and return the result, also as a TStream descendant. If you cannot find this easily just say it, I've got the code (or at the very least these two functions) lying around.

If I just said anything anyone has already mentioned, please forgive me, I've only just read this message and thought to elaborate a bit on it :-) 


--
Ewald




More information about the fpc-pascal mailing list