zlib 的多文件压缩,解压问题?

sefeng1982 sefeng1982 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
想把以下这个代码改成多文件的解压,压缩已经自己做好了,解压怎么弄都是错的!~~~
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;
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
sefeng1982
Delphi 5,945 成员 262,941 内容