uses ZLib, SysUtils;
Packen:
procedure Compress(InputFileName, OutputFileName:
string);
var InputStream, OutputStream: TFileStream;
CompressionStream:
ZLib.TCompressionStream;
begin
InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
try
OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
try
CompressionStream:=TCompressionStream.Create(clMax, OutputStream);
try
CompressionStream.CopyFrom(InputStream, InputStream.Size);
finally
CompressionStream.Free;
end;
finally
OutputStream.Free;
end;
finally
InputStream.Free;
end;
end;
Entpacken:
procedure Decompress(InputFileName, OutputFileName:
string);
var InputStream, OutputStream: TFileStream;
DeCompressionStream:
ZLib.TDeCompressionStream;
begin
InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
try
OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
try
DecompressionStream:=TDecompressionStream.Create(OutputStream);
try
DecompressionStream.CopyFrom(InputStream, InputStream.Size);
finally
DecompressionStream.Free;
end;
finally
OutputStream.Free;
end;
finally
InputStream.Free;
end;
end;