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

sefeng1982 2011-09-26 05:53:35
想把以下这个代码改成多文件的解压,压缩已经自己做好了,解压怎么弄都是错的!~~~
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;
...全文
145 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧