Creating compressed file stream
Easy Compression Library provides a file stream interface with TECLFileStream class that has two standard parameters (FileName, Mode) in constructor and two extended parameters (Password and CompressionLevel).
When the Password parameter is not blank, it is used to encrypt the file (except the case when CompressionLevel is eclNone).
CompressionLevel indicates the algorithm and mode that is used for file compression.
When CompressionLevel is eclNone (by default), TECLFileStream is equal to TFileStream, i.e. it could be used to read from/write to usual non-compressed file.
The following example illustrates how to create encrypted file with fastest compression using TECLFileStream.
Example:
var
CompFS: TECLFileStream;
begin
CompFS := TECLFileStream.Create('c:\test_comp.ecl', fmCreate, 'Password', zlibFastest);
CompFS.LoadFromFile('c:\test.txt');
CompFS.Free;
end;
|