Registriert seit: 21. Apr 2004
11 Beiträge
|
Re: Gezipte Daten entpacken
5. Jun 2004, 18:39
also ich weis net wo ichs her hab aber so siets aus:
packen:
Delphi-Quellcode:
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;
und entpacken
Delphi-Quellcode:
procedure Decompress(InputFileName, OutputFileName: string);
var InputStream, OutputStream: TFileStream;
DeCompressionStream: ZLib.TDeCompressionStream;
Buf: array[0..4095] of Byte;
Count: Integer;
begin
InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
try
OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
try
DecompressionStream := TDecompressionStream.Create(InputStream);
try
while true do
begin
Count := DecompressionStream. Read(Buf[0], SizeOf(Buf));
if Count = 0 then
break
else
OutputStream. Write(Buf[0], Count);
end;
finally
DecompressionStream.Free;
end;
finally
OutputStream.Free;
end;
finally
InputStream.Free;
end;
end;
|
|
Zitat
|