Re: [bds 2006] Decompress .gz files with zlib unit?
- From: "Richard A. DeVenezia" <rdevenezia@xxxxxxxxxxxx>
- Date: Tue, 24 Jan 2006 23:16:16 -0500
Wolfgang Ehrhardt wrote:
> gz files (normally) are gzip compressed files. The gzip stream format
> is slightly different from plain zlib streams, although gzip I/O can
> be implemented with zlib, as it is shown with the gzio.c file in the
> zlib distribution. zlib versions newer that 1.1.4 have enhanced gzip
> support.
>
> All versions of Delphi (that I know of) do have a "own" (sub-optimal)
> interface to zlib. Delphi uses the C compiled obj files (and gzio.obj
> is missing),
Thanks Wolfgang:
I have been trying to use a zlib 1.2.3 unit download from
http://www.base2ti.com/cgi-bin/download.exe?folder=delphi+zlib&file=delphi+zlib+1.2.3
The ZLibEx.pas has two TZDecompressionStream constructors
-----------
constructor TZDecompressionStream.Create(source: TStream);
begin
inherited Create(source);
FZStream.next_in := FBuffer;
FZStream.avail_in := 0;
ZDecompressCheck(InflateInit(FZStream));
end;
constructor TZDecompressionStream.Create(source: TStream;
windowBits: Integer);
begin
inherited Create(source);
FZStream.next_in := FBuffer;
FZStream.avail_in := 0;
ZDecompressCheck(InflateInit2(FZStream,windowBits));
end;
-----------
>From what I understand (zlib.h), *Init is for zlib wrapped and the *Init2 is
for gzip wrapped. That being I would presume to want to do something like
[ note the ,12 -- the second form of the constructor that uses
InflateInit2 ]
------------------------
bufferSize := 1000;
GetMem (pBuffer, bufferSize);
z := TZDecompressionStream.Create(TFileStream.Create(gzfile,
fmOpenRead),12);
bytesRead := z.Read(pBuffer^, bufferSize);
z.Free();
WriteLn (bytesRead, ' bytes read.');
WriteLn (String(pBuffer^));
FreeMem(pBuffer, bufferSize);
WriteLn('Done.');
ReadLn;
------------------------
Unfortunately, this raises a Data Error exception.
--
Richard A. DeVenezia
http://www.devenezia.com/
.
- Follow-Ups:
- Re: [bds 2006] Decompress .gz files with zlib unit?
- From: Wolfgang Ehrhardt
- Re: [bds 2006] Decompress .gz files with zlib unit?
- References:
- [bds 2006] Decompress .gz files with zlib unit?
- From: Richard A. DeVenezia
- Re: [bds 2006] Decompress .gz files with zlib unit?
- From: Wolfgang Ehrhardt
- [bds 2006] Decompress .gz files with zlib unit?
- Prev by Date: Re: [bds 2006] Decompress .gz files with zlib unit?
- Next by Date: Re: Recommendations for a text to speech component?
- Previous by thread: Re: [bds 2006] Decompress .gz files with zlib unit?
- Next by thread: Re: [bds 2006] Decompress .gz files with zlib unit?
- Index(es):
Relevant Pages
|