How to uncompress gzip archive compressed by deflate method.

div0 div0 at sourceforge.net
Fri Nov 12 15:58:36 PST 2010


On 12/11/2010 23:33, Zarathustra wrote:
> Maybe it is a stupid question but I need yours help.
> As in the topic. I have a Gzip archive in the buffer and I need to extract
> these archive into another buffer.
>
> I tried: void[] _uncompressed = uncompress(_compressed);
>
> but it throws 'std.zlib.ZlibException: data error.'
>
> Is it possible to do with Phobos2 ? The archive is not corrupted because It
> works fine after saving on the disk.
>
> Thanks in advance.

A Gzipp'd file will start with a Gzip header and the uncompress function 
(probably) expects to be given a pointer the first byte of the 
compressed data, i.e. not a pointer to the header.

You probably just need to add an offset == to the size of the gzip 
header to the start of your data.

There's a full interface to zlib available in phobo\etc\c\zlib.d. so 
have a look through there.

-- 
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk


More information about the Digitalmars-d-learn mailing list