(CodeLib-Manager)
Registriert seit: 10. Jun 2002
4.648 Beiträge
Delphi XE Professional
|
Re: Crosspost: Compressed Data in Datei auslesen
23. Apr 2008, 06:17
Hallo,
Vielleicht gibt die UnitIdCompressionIntercept.pas ein wenig Aufschluss darüber, wie inflateInit etc. zu verwenden ist oder die ZlibEx im Anhang, insb:
Delphi-Quellcode:
procedure ZDecompress(const inBuffer: Pointer; inSize: Integer;
out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer);
var
zstream: TZStreamRec;
delta: Integer;
begin
FillChar(zstream, SizeOf(TZStreamRec), 0);
delta := (inSize + 255) and not 255;
if outEstimate = 0 then outSize := delta
else outSize := outEstimate;
GetMem(outBuffer, outSize);
try
zstream.next_in := inBuffer;
zstream.avail_in := inSize;
zstream.next_out := outBuffer;
zstream.avail_out := outSize;
ZDecompressCheck(InflateInit(zstream));
try
while ZDecompressCheck(inflate(zstream, Z_NO_FLUSH)) <> Z_STREAM_END do
begin
Inc(outSize, delta);
ReallocMem(outBuffer, outSize);
zstream.next_out := PChar(Integer(outBuffer) + zstream.total_out);
zstream.avail_out := delta;
end;
finally
ZDecompressCheck(inflateEnd(zstream));
end;
ReallocMem(outBuffer, zstream.total_out);
outSize := zstream.total_out;
except
FreeMem(outBuffer);
raise;
end;
end;
Thomas
|
|
Zitat
|