<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Werner Pamler wrote:<br>
<blockquote cite="mid:5648F514.30806@freenet.de" type="cite">Another
question: I would prefer to avoid Abbrevia altogether and use the
standard zip support in fpc. There are examples in the wiki on how
to use the TDecompressionStream for inflating gzip files. But I
always get a "data error"at least with the mailinglist archive
files from <a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/pipermail/lazarus/">http://lists.lazarus.freepascal.org/pipermail/lazarus/</a>.
If I use a TGZFileStream instead of the TDecompressionStream by a
TGZFileStream, then the file decompresses fine. But this is not a
good solution as I would have to use temporary files which I want
to avoid. How can the TGZFileStream be modified such that it
accepts a stream as input parameter instead of a filename?
<br>
</blockquote>
It should be possible to use inflateInit2 from paszlib.<br>
I've found a snippet here: <a class="moz-txt-link-freetext" href="http://www.gocher.me/GZIP">http://www.gocher.me/GZIP</a><br>
<br>
If you take GZIPUtils.pas, at first you think it should work, but it
didn't. The only thing I found was that that code only takes a
header of 9 bytes into account while the 2015-November.txt.gz has a
header of 71 bytes. So if I change the following in
ZUncompressStream I could successfully extract 2015-November.txt:<br>
<br>
On line 178:<br>
// inStream.Position := 10; // jump over header<br>
inStream.Position := 72; // jump over header, this needs to be
adjusted to read a string until #0<br>
<br>
========<br>
procedure TForm1.Button1Click(Sender: TObject);<br>
var<br>
inStream, outStream: TMemoryStream;<br>
begin<br>
inStream := TMemoryStream.Create;<br>
outStream := TMemoryStream.Create;<br>
try<br>
inStream.LoadFromFile('c:\temp\2015-November.txt.gz');<br>
if ZUncompressStream(inStream, outStream) then<br>
begin<br>
outStream.SaveToFile('c:\temp\2015-November.txt');<br>
end;<br>
finally<br>
inStream.Free;<br>
outStream.Free;<br>
end;<br>
end;<br>
========<br>
Of course in your final code you should read a string until #0 from
the file and position it correctly to begin at the real data.<br>
<br>
You could also strip the deflate-part of that unit (or completely
create your own implementation from this source). It's not much code
after you strip all the things you don't need.<br>
<br>
Grtz,<br>
<i>Rik</i> (rvk on forum)<br>
<br>
</body>
</html>