Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif /img/help/prev.gif /img/help/disnext.gif

 

Adding a custom header

 


 

Typically all the data you put in ECL streams is compressed. But sometimes, you might want to have a custom not compressed header in compressed file or in some other resource associated with ECL stream.

 

This custom header could be used to store information that is small, but should be often updated, so the compression is unnecessary here.

 

Another example of using not compressed header is a need to have some data in compressed file that could be accessed, even if the file is encrypted and we don't know the password. In such a way we could store a name of the owner of the file, and this information is accessible even from encrypted file.

 

Creating header in a new file or other resource

To create not compressed header in a new file or other resource associated with the stream, just pass the size of the header as the CustomHeaderSize parameter in TECLFileStream, TECLMemory or TECLStream constructor.

Note: The size of the header couldn't be changed later.

 

Accessing header from ECL streams

To read from or write to the header in existing ECL stream, use the CompressedDataStream property. This header data area is started at ECLStreamHeaderSize byte. This value should be used as a start position in CompressedDataStream. The size of the header could be known from CustomHeaderSize property of ECL stream.

 

Accessing header without ECL stream

If you use other streams, such as TFileStream to access the data of the header, you should do the following:

  1. Get the size of a custom header, by reading 4 bytes from CustomHeaderSizeOffset offset.
  2. Read header data, starting from ECLStreamHeaderSize offset.
  3. All these offsets are calculated from the beginning of the file or the resource.

    CustomHeaderSizeOffset and ECLStreamHeaderSize are the constants defined in EasyCompression unit.

     

    Note:

    See also the CustomHeader sample application in Demos folder.

     

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Mar 29, 2024