zlib 的多文件压缩,解压问题?
想把以下这个代码改成多文件的解压,压缩已经自己做好了,解压怎么弄都是错的!~~~
procedure ZInternalDecompressStream(zstream: TZStreamRec; inStream,
outStream: TStream);
const
bufferSize = 32768;
var
zresult : Integer;
inBuffer : Array [0..bufferSize-1] of Byte;
outBuffer: Array [0..bufferSize-1] of Byte;
outSize : Integer;
begin
try
zresult := Z_OK;
zstream.avail_in := inStream.Read(inBuffer, bufferSize); //实际读入的数据
while (zresult <> Z_STREAM_END) and (zstream.avail_in > 0) do
begin
zstream.next_in := @inBuffer;//数据地址
repeat
zstream.next_out := @outBuffer;
zstream.avail_out := bufferSize;
zresult := ZDecompressCheck(ZInflate(zstream, zfNoFlush), False);
outSize := bufferSize - zstream.avail_out;
//outSize:=
outStream.Write(outBuffer, outSize);
until (zresult = Z_STREAM_END) or (zstream.avail_out > 0);
if zstream.avail_in > 0 then
begin
inStream.Position := inStream.Position - zstream.avail_in;
end;
if zresult <> Z_STREAM_END then
begin
zstream.avail_in := inStream.Read(inBuffer, bufferSize);
end;
end;
finally
ZDecompressCheck(ZInflateEnd(zstream));
end;
end;