Re: [bds 2006] Decompress .gz files with zlib unit?



On Tue, 24 Jan 2006 11:33:09 -0500, "Richard A. DeVenezia"
<rdevenezia@xxxxxxxxxxxx> wrote:

>Haven't used Delphi in ages, starting back up with bds 2006.
>
>I have a bunch of .gz files that need to be decompressed (on the fly) before
>I can use the data inside them.
>
>The files are not corrupt -- WinZip was unable decompress them.
>
>The simple console program below raises an Application Error dialog
> "The exception unknown software exception (0x0eedfade) occurred in the
>application at location 0x7c59bc3f"
>and writes out
> Exception ECompressionError in module Project2.exe at 00010AA7.
> Error.
>
>Have I missed something?
>Do I need a different decompression library ?
>

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), but there are source code ports from c to pascal/delphi.
e.g. my own V1.1.4 (tested up to Delphi 9 aka 2005)
<http://home.netsurf.de/wolfgang.ehrhardt/zlibw114_2005-08-03.zip>
it based on Jacques Nomssi Nzali's Pascal port of zlib 1.1.2 available
from <http://www.nomssi.de/paszlib/paszlib.html> (beware of some
bugs!)

Another way of decompressing the gz files is: spawning gzip.exe either
to directly unpack file.ext.gz to file.ext or using the -c option to
redirect to stdout.

Hope that helps

Wolfgang
--
In order to e-mail me a reply to this message, you will have
to remove PLEASE.REMOVE from the address shown in the header
or get it from http://home.netsurf.de/wolfgang.ehrhardt
(Free AES, CRC, Hash, and HMAC source for Pascal/Delphi)
.



Relevant Pages

  • Re: ZLIB, GZIP, COMPRESS
    ... I dont really understand why ZLIB cannot uncompress files produced by COMPRESS. ... had a file that you could decompress with gzip, ... Gunzip will decompress files created by compress, ...
    (comp.compression)
  • Re: Gzip component, module, or code?
    ... > lots of gzip stuff for Delphi, but I can't be sure if any of it will ... > compatible/decompressable by a PHP server script running on a Apache ... If you use zlib to compress it under Delphi then you can use PHP's zlib ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Problems using zlib - any help? Solved...
    ... to decompress a "naked" (no headers of any kind) deflate stream. ... allows you to ask for gzip decoding, ... hadn't "hit the wall" of thinking I should be using inflateInit(), ...
    (comp.compression)
  • Re: [bds 2006] Decompress .gz files with zlib unit?
    ... > gz files are gzip compressed files. ... > is slightly different from plain zlib streams, ... constructor TZDecompressionStream.Create; ... GetMem (pBuffer, bufferSize); ...
    (comp.lang.pascal.delphi.misc)
  • Re: zlib with gzip file
    ... That does raw inflation, not gzip decoding. ... For background, a zlib ... different header - deflate data - different trailer. ...
    (comp.compression)