Compressing a whole custom stream: Example
The following example illustrates how to compress and decompress the whole file stream to a memory stream.
var
mStream: TMemoryStream;
fStream: TFileStream;
begin
mStream := TMemoryStream.Create;
fStream := TFileStream.Create('c:\test.txt', fmOpenReadWrite or fmShareDenyNone);
ECLCompressStream(fStream, mStream, '', bzipNormal);
mStream.SaveToFile('c:\test.ecl');
mStream.Free;
fStream.Free;
mStream := TMemoryStream.Create;
fStream := TFileStream.Create('c:\test.ecl', fmOpenReadWrite or fmShareDenyNone);
ECLDecompressStream(fStream, mStream, '');
mStream.SaveToFile('c:\test_dec.txt');
mStream.Free;
fStream.Free;
end;
|