Start Page

Aravil CAB Components 1.20 for Borland Delphi 5 and 6

This toolkit consists of two native VCL components TSTCabReader and TSTCabWriter. Using these components, you can easily create CAB archives and then extract files from archives. The components are just wrappers over Microsoft Cabinet.dll. They simplify your work with archives and add useful capabilities.

This software is freeware. You can use it for your commercial software or for your own use.

Components

  • TSTCabReader
  • T STCabWriter

Supported definitions

  • TSTCabCompressionType
  • TSTCabLzxLevel
  • TSTCabAddFileOption, TSTCabAddFileOptions
  • TSTCabAddFilesOption, TSTCabAddFilesOptions
  • TSTCabExtractFilesOption, TSTCabExtractFilesOptions

Microsoft Cabinet definitions

  • TCOMP
  • TCCAB
  • TFDICABINETINFO
  • TFDINOTIFICATION

Units

  • CabIntf
  • CabSTComps
  • CabSTConsts
  • CabSTReg

See also

  • Components Installation
  • Tutorial: Compressing
  • Tutorial: Extracting
  • FAQ
  • History
  • License

Aravil Software

web site - aravilsoft.tripod.com
e-mail - aravilsoft@bigfoot.com or wizeman@mail.ru

Copyright © Ravil Batyrshin, 2001-2002. All rights reserved.


Components Installation.

For installation add unit CabSTReg to any your package or to new package. By default components are added to the Samples palette page.


Tutorial: Compressing.

For compressing files to archives you have to use TSTCabWriter component.

You can place the component on form, set its properties and assign events handlers at design-time. Or you can create the component at run-time and then set its properties and assign events handlers.

The common scenario is like:

  1. Create the component.
  2. Set properties (compression type, various thresholds).
  3. Assign events handlers if needed.
  4. Open an archive.
  5. Add files to the archive.
  6. Close the archive. Don't forget to do it!
  7. Free the component.

Example:

procedure TForm1.CompressBtnClick(Sender: TObject);
var
   aCabWr: TSTCabWriter;
begin
   aCabWr := TSTCabWriter.Create(nil);
   try
      aCabWr.CompressionType := cctMsZip;
      aCabWr.Open('C:\TEMP\test.cab');

      aCabWr.AddFile('C:\My Downloads\Prices\books.xls', 'books.xls');
      aCabWr.AddFile('C:\My Downloads\Prices\price1.xls', 'comps\price1.xls');
      aCabWr.AddFile('C:\My Downloads\Prices\price2.xls', 'comps\price2.xls');
      aCabWr.AddFiles('C:\Data\*', 'Data', [cafsoRecurseSubdirs]);

      aCabWr.Close;
   finally
      aCabWr.Free;
   end;
end;

By default the component is configured for maximum compression ratio. Assign needed values to the thresholds and choice proper compression type and level.


Tutorial. Extracting

Tutorial: Extracting.

For extracting files from archives you have to use TSTCabReader component.

You can place the component on form, set its properties and assign events handlers at design-time. Or you can create the component at run-time and then set its properties and assign events handlers.

The common scenario is like:

  1. Create the component.
  2. Set properties if needed.
  3. Assign events handlers if needed.
  4. Extract files from cabinet.
  5. Free the component.

Example:

procedure TForm1.ExtractBtnClick(Sender: TObject);
var
   aCabRd: TSTCabReader;
begin
   aCabRd := TSTCabReader.Create(nil);
   try
      aCabRd.ExtractFiles('C:\TEMP\test.cab', 'C:\Temp\2');
   finally
      aCabRd.Free;
   end;
end;

For controling what files need to extract you need to assign handler to OnCopyFile event.


TSTCabWriter component

This component is used for compressing files into a CAB archive.

Syntax

type
   TSTCabWriter = class(TComponent);

Properties

Property | Description
CabinetFileCountThreshold | Threshold for the number of files to store in a CAB file.
CabinetNameTemplate | Template for CAB files names.
CabinetPathTemplate | Template for CAB files pathes.
CabinetSizeThreshold | Threshold size for a CAB file.
CompressionLzxLevel | Level of LZX compression.
CompressionType | Type of compression method.
DiskLabelTemplate | Template for disk labels of CAB files.
FileName | Full file name of an archive.
FolderFileCountThreshold | Threshold for the number of files to store in a folder.
FolderSizeThreshold | Threshold size for a folder.
Handle | FCI context handle.
ReservePerCabinetSize | Amount of additional space to reserve for the cabinet.
ReservePerDataSize | Amount of additional space to reserve for each data block in the cabinet.
ReservePerFolderSize | Amount of additional space to reserve for each folder in the cabinet.
SetID | Identificator of the cabinet.

Methods

Method | Description
AddFile | Compress a single file to an archive.
AddFiles | Compress files that match a mask to an archive.
Close | Close a CAB file.
Open | Open a new CAB file.
StartNewCabinet | Start a new cabinet.
StartNewFolder | Start a new folder.

Events

Event | Description
OnBeforeFileAdd | Occurs just before adding a file to a cabinet.
OnCabinetStatus | Occurs when a cabinet has been writed out on a hard disk.
OnFilePlaced | Occurs whenever the location of a file or file segment on a particular cabinet has been finalized.
OnFileStatus | Occurs when following data blocks of a file have been compressed into a folder.
OnFolderStatus | Occurs when a folder has been copied to a cabinet.
OnGetNextCabinet | Occurs whenever cabinet size or stored file count reached thresholds.
OnProgress | Occurs periodically during compressing files to a cabinet.

See Also

Tutorial: Compressing
TSTCabReader


TSTCabReader component

This component is used for extracting files from a CAB archive.

Syntax

type
   TSTCabReader = class(TComponent);

Properties

Property | Description
DstPath | Destination path for extracting files.
CurrentFileName | Full file name of the current CAB archive volume.
FileName | Full file name of a CAB archive.
Handle | FDI context handle.
IsOnPartialFile | Determines whether a CAB archive volume is being processed cause file splitting between volumes.
NextFileName | Full file name of the next CAB archive volume.
NextDiskName | Disk name of the next CAB archive volume.
Options | Defines options.

Methods

Method | Description
EnumFilesEntries | Enumerates files in a CAB archive.
ExtractFiles | Extracts files from a CAB archive.
IsCabinet | Determines whether a file is a CAB archive.

Events

Event | Description
OnCabinetInfo | Provides general information about cabinet during extracting.
OnCloseFile | Occurs after file extracting.
OnCopyFile | Occurs before file extracting.
OnCopyPartialFile | Occurs on extracting file which is a continuation from previous cabinet.
OnNextCabinet | Occurs when extracted file continued on next cabinet.
OnUnrecognizedNotify | Occurs on unrecognized notification from FDI during extracting.

Remarks

For extracting files from a CAB archive use ExtractFiles method.

See Also

Tutorial: Extracting
TSTCabWriter


History

1.20

  • Added EnumFilesEntries method to TSTCabReader.

1.10

  • Added new parameter anOptions to ExtractFiles method of TSTCabReader component. Now you can extract files only from one volume of archive.
  • Added check "next filename" must be not equal "current filename" to ExtractFiles method of TSTCabReader.

1.09

  • Added OnBeforeFileAdd event to TSTCabWriter.

1.08

  • Fixed bug: at multi-volume extracting several files are not extracted if file splitting between volumes are present. Thanks to Rainer Geigenberger.
  • Added CurrentFileName, IsOnPartialFile properties to TSTCabReader.

1.07

  • At extracting supplied Win32 error information.
  • At extracting processed aborting at OnGetNextCabinet event for first cabinet volume.

1.06

  • Fixed bug: terminate extracting at attempt to overwrite read-only file.
  • Added croDontOverwriteReadOnlyFiles to TSTCabReaderOption.

1.05

  • Added NextFileName, NextDiskName properties to TSTCabReader.
  • Realized forced extracting of multi-volume archives. Be careful, because behavior of multi-volume extracting has been changed slightly!

1.04

  • Added support for Delphi 5. Thanks to Norbert Hagemann.

1.03

  • Added Options property to TSTCabReader.
  • Realized file execution on extracting.

1.02

  • Release for Delphi 6.


FAQ

I want to archive on diskettes. Can I use the OnGetNextCabinet event to ask the user to insert a new diskette for the next volume of archive?
Unfortunately Microsoft raises GetNextCabinet event arbitrarily, therefore you cannot use this one to prompt for diskette changing. The good solution is to create the archive somewhere on the hard disk, for example in the TEMP folder, and then to copy it on diskettes.
Similarly for restoring files from diskettes, first copy all volumes of archive on the hard disk and then unarchive it.
At unarchiving multivolume archive not all volumes are processed.
If the file is splitted between volumes Microsoft itself tries to unarchive the following volume of archive. Similarly the component if finds out the information in current volume about the following volume and finds this volume in the same directory, tries to unarchive the following volume. If these conditions are not fulfilled to you it is necessary to initiate the process of unarchiving of the following volume of archive.
If an error occured do the component produce the detailed information about the error? The disk is full and so on.
Only what are given by Microsoft Cabinet.dll. Look at TFDIERROR, TFCIERROR enums.
What is folder in a context of CAB-file?
. . .


END USER LICENSE AGREEMENT ("EULA")

This is a legal agreement between you and Aravil Software.

LICENSE

This software is freeware. You may use it for your commercial software or for your own use. You may not sell these components as is or with some changes.

LIMITED WARRANTY AND DISCLAIMER

No warranties are given to you. All your possible demands will be disclaimed.

(USA ONLY) SOME STATES DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. IN THIS CASE USE ANOTHER SOFTWARE.

LIMITATION OF LIABILITY

No liabilities are given to you. All your possible demands will be disclaimed.

(USA ONLY) SOME STATES DO NOT ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OF CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU. IN THIS CASE USE ANOTHER SOFTWARE.

Thank you.


TCCAB type

Parameters for creating cabinet.

Syntax

const
   CB_MAX_FILENAME =            256;
   CB_MAX_CABINET_NAME =        256;
   CB_MAX_CAB_PATH =            256;
   CB_MAX_DISK_NAME =           256;

type
   TCCAB = record
      cb: ULONG;                  // size available for cabinet on this media
      cbFolderThresh: ULONG;      // Thresshold for forcing a new Folder
      cbReserveCFHeader: UINT;    // Space to reserve in CFHEADER
      cbReserveCFFolder: UINT;    // Space to reserve in CFFOLDER
      cbReserveCFData: UINT;      // Space to reserve in CFDATA
      iCab: Integer;              // sequential numbers for cabinets
      iDisk: Integer;             // Disk number
      fFailOnIncompressible: Integer;  // TRUE => Fail if a block is incompressible
      setID: USHORT;               // Cabinet set ID
      szDisk: array[0..CB_MAX_DISK_NAME - 1] of AnsiChar;    // current disk name
      szCab: array[0..CB_MAX_CABINET_NAME - 1] of AnsiChar;  // current cabinet name
      szCabPath: array[0..CB_MAX_CAB_PATH - 1] of AnsiChar;  // path for creating cabinet
   end;

   PCCAB = ^TCCAB;

Remarks

iCab is 0 for the first cabinet, 1 for the second cabinet, etc.

iDisk is 1 for the first cabinet, 2 for the second cabinet, etc.

setID is randomly chosen number. This number must be the same for all splited cabinets.

szCabPath must end with a trailing delimiter.

See Also

TSTCabWriter.OnGetNextCabinet


TCOMP type

Parameters for file compression.

Syntax

type TCOMP = USHORT;

const
   tcompMASK_TYPE =          $000F;  // Mask for compression type
   tcompTYPE_NONE =          $0000;  // No compression
   tcompTYPE_MSZIP =         $0001;  // MSZIP
   tcompTYPE_QUANTUM =       $0002;  // Quantum
   tcompTYPE_LZX =           $0003;  // LZX
   tcompBAD =                $000F;  // Unspecified compression type

   tcompMASK_LZX_WINDOW =    $1F00;  // Mask for LZX Compression Memory
   tcompLZX_WINDOW_LO =      $0F00;  // Lowest LZX Memory (15)
   tcompLZX_WINDOW_HI =      $1500;  // Highest LZX Memory (21)
   tcompSHIFT_LZX_WINDOW =       8;  // Amount to shift over to get int

   tcompMASK_QUANTUM_LEVEL = $00F0;  // Mask for Quantum Compression Level
   tcompQUANTUM_LEVEL_LO =   $0010;  // Lowest Quantum Level (1)
   tcompQUANTUM_LEVEL_HI =   $0070;  // Highest Quantum Level (7)
   tcompSHIFT_QUANTUM_LEVEL =    4;  // Amount to shift over to get int

   tcompMASK_QUANTUM_MEM =   $1F00;  // Mask for Quantum Compression Memory
   tcompQUANTUM_MEM_LO =     $0A00;  // Lowest Quantum Memory (10)
   tcompQUANTUM_MEM_HI =     $1500;  // Highest Quantum Memory (21)
   tcompSHIFT_QUANTUM_MEM =      8;  // Amount to shift over to get int

   tcompMASK_RESERVED =      $E000;  // Reserved bits (high 3 bits)

Remarks

Parameters bitwise ORed.

See Also

TSTCabWriter.AddFile
 TSTCabWriter.AddFiles


TFDICABINETINFO type

Information about CAB file.

Syntax

type
   TFDICABINETINFO = record
      cbCabinet: Longint;  // Total length of cabinet file
      cFolders: USHORT;    // Count of folders in cabinet
      cFiles: USHORT;      // Count of files in cabinet
      setID: USHORT;       // Cabinet set ID
      iCabinet: USHORT;    // Cabinet number in set (0 based)
      fReserve: WIN_BOOL;  // TRUE => RESERVE present in cabinet
      hasprev: WIN_BOOL;   // TRUE => Cabinet is chained prev
      hasnext: WIN_BOOL;   // TRUE => Cabinet is chained next
   end;

   PFDICABINETINFO = ^TFDICABINETINFO;

See Also

TSTCabReader.IsCabinet


TFDINOTIFICATION type

Structure with some or all of the fields filled out, depending on the extracting event type.

Syntax

type
   TFDINOTIFICATION = record
      cb: Longint;
      psz1: PAnsiChar;
      psz2: PAnsiChar;
      psz3: PAnsiChar;       // Points to a 256 character buffer
      pv: PVoid;             // Value for client
      hf: Integer;
      date: USHORT;
      time: USHORT;
      attribs: USHORT;

      setID: USHORT;         // Cabinet set ID
      iCabinet: USHORT;      // Cabinet number (0-based)
      iFolder: USHORT;       // Folder number (0-based)

      fdie: TFDIERROR;
   end;

   PFDINOTIFICATION = ^TFDINOTIFICATION;

See Also

TSTCabReader.OnUnrecognizedNotify


TSTCabAddFileOption, TSTCabAddFileOptions types

Options for file compression.

Syntax

type
   TSTCabAddFileOption = (cafoExecuteOnExtract);
   TSTCabAddFileOptions = set of TSTCabAddFileOption;

Remarks

The cafoExecuteOnExtract specifies whether the file should be executed automatically when the cabinet is extracted.

See Also

TSTCabWriter.AddFile
 TSTCabReader.OnCloseFile


TSTCabAddFilesOption, TSTCabAddFilesOptions types

Options for files storing.

Syntax

type
   TSTCabAddFilesOption = (cafsoRecurseSubdirs);
   TSTCabAddFilesOptions = set of TSTCabAddFilesOption;

Remarks

The cafsoRecurseSubdirs specifies whether need to process subdirectories.

See Also

TSTCabWriter.AddFiles


TSTCabCompressionType type

Defines how files are stored in cabinents.

Syntax

type
    TSTCabCompressionType = (cctNone, cctMsZip, cctLzx);
Value | Meaning
cctNone | Store without compression
cctMsZip | Store with MSZIP compression
cctLzx | Store with LZX compression

Remarks

LZX can archive higher compressions ratios than others. Its compression requires more time, but decompression is typically faster.

See Also

TSTCabWriter.CompressionType


TSTCabExtractFilesOption, TSTCabExtractFilesOptions types

Options for files extracting.

Syntax

type
   TSTCabExtractFilesOption = (
      cefsoProcessOnlyOneVolume
   );

   TSTCabExtractFilesOptions = set of TSTCabExtractFilesOption;

Remarks

The cefsoProcessOnlyOneVolume specifies need to extract files only from one volume of archive.

See Also

TSTCabReader.ExtractFiles


TSTCabLzxLevel type

Defines how files are stored in cabinents.

Syntax

TSTCabLzxLevel = 15..21;

See Also

TSTCabWriter.CompressionLzxLevel


CurrentFileName property (TSTCabReader component)

Full file name of the current CAB archive volume.

Syntax

property CurrentFileName: String;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method.

See Also

TSTCabReader.ExtractFiles


DstPath property (TSTCabReader component)

Destination path for extracting files.

Syntax

property DstPath: String;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method.

See Also

TSTCabReader.ExtractFiles


EnumFilesEntries method (TSTCabReader component)

Enumerates files in a CAB archive.

Syntax

type
   TSTCabReaderEnumFilesEntriesEvent = procedure(
      Sender: TSTCabReader;
      const aFileName: String;
      anUncompressedSize: UINT4;
      aFlags: UINT2;
      aDate, aTime, anAttrs: UINT2;
      var anAbort: Boolean) of object;

   function EnumFilesEntries(const aFileName: String;
      aCallback: TSTCabReaderEnumFilesEntriesEvent): Boolean;

Parameters

aFileName
CAB archive file name.
aCallback
Callback function that is called for each file in the archive.

Return Values

Returns True if the file is a CAB archive. Else returns False.

Remarks

If _A_NAME_IS_UTF is set in the anAttrs then file name is UTF encoded.


ExtractFiles method (TSTCabReader component)

Extracts files from a CAB archive.

Syntax

procedure ExtractFiles(const aFileName, aDstPath: String;
   anOptions: TSTCabExtractFilesOptions = []);

Parameters

aFileName
CAB archive file.
aDstPath
Destination path for extracting files.
anOptions
Options for extracting files.

Remarks

If archive is splited into several files (volumes), its volumes will be processed automatically. But due some reasons (wrong split of volumes and as result absence of information of the next volume, or file of the next volume not found) this may not be occurred. You have to control this situation and invoke ExtractFiles for the next volume of the archive.

See Also

TSTCabExtractFilesOptions
FileName
DstPath


FileName property (TSTCabReader component)

Full file name of a CAB archive.

Syntax

property FileName: String;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method.

See Also

TSTCabReader.ExtractFiles


Handle property (TSTCabReader component)

FDI context handle.

Syntax

property Handle: HFDI;

Remarks

Read-Only. Usually you don't use it.


IsCabinet method (TSTCabReader component)

Determines whether a file is a CAB archive.

Syntax

function IsCabinet(const aFileName: String;
   var aCabInfo: TFDICABINETINFO): Boolean;

Parameters

aFileName
The name of the testing file.
aCabInfo
This structure will receive the cabinet details if the file is indeed a cabinet.

Return Values

If the file is CAB archive, the return value is True.

Else the return value is False.

Remarks

The IsCabinet method determines whether a given file is a CAB archive, and if so, returns information about the cabinet in the provided TFDICABINETINFO structure.

See Also

TFDICABINETINFO


IsOnPartialFile method (TSTCabReader component)

IsOnPartialFile property (TSTCabReader component)

Determines whether a CAB archive volume is being processed cause file splitting between volumes.

Syntax

property IsOnPartialFile: Boolean;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method.


NextDiskName property (TSTCabReader component)

Disk name of the next CAB archive volume.

Syntax

property NextDiskName: String;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method and OnCabinetInfo event.

See Also

TSTCabReader.ExtractFiles
TSTCabReader.OnCabinetInfo


NextFileName property (TSTCabReader component)

Full file name of the next CAB archive volume.

Syntax

property NextFileName: String;

Remarks

Read-Only. This property has meaning value only after ExtractFiles method and OnCabinetInfo event.

See Also

TSTCabReader.ExtractFiles
TSTCabReader.OnCabinetInfo


OnCabinetInfo event (TSTCabReader component)

Provides general information about cabinet volume during extracting.

Syntax

type
   TSTCabReaderCabinetInfoEvent = procedure(
      Sender: TSTCabReader;
      const aNextCabName, aNextDiskName, aCabPath: String;
      aSetID, aCabNo: USHORT; var anAbort: Boolean) of object;

property OnCabinetInfo: TSTCabReaderCabinetInfoEvent;

Parameters

Sender
Object whose event handler is called.
aNextCabName
Name of the next cabinet file.
aNextDiskName
Name of the next disk.
aCabPath
Cabinet path.
aSetID
Identifation of the cabinet.
aCabNo
Number of the cabinet within the cabinet set (0 for the first cabinet).
anAbort
Abort extracting. Upon entry into the handler, this parameter equals False.

Remarks

Occurs for each cabinet volume during extracting.


OnCloseFile event (TSTCabReader component)

Occurs after file extracting.

Syntax

type
   TSTCabReaderCloseFileEvent = procedure(
      Sender: TSTCabReader;
      const aSrcFileName: String;
      aDate, aTime, anAttrs, aFolderNo: USHORT;
      var anExec: Boolean;
      const aDstFullFileName: String;
      var anAbort: Boolean) of object;

property OnCloseFile: TSTCabReaderCloseFileEvent;

Parameters

Sender
Object whose event handler is called.
aSrcFileName
Name of a file in the cabinet.
aDate
File's 16-bit FAT date.
aTime
File's 16-bit FAT time.
anAttrs
File's 16-bit FAT attributes.
aFolderNo
Folder number where the file lies.
anExec
Execute file. Upon entry into the handler, this parameter equals True if the file was marked for executing. You can reset this flag to False. Also executing is defined by Options property.
aDstFullFileName
Name of the file where it was extracted. Can be empty due some cause!
anAbort
Abort extracting. Upon entry into the handler, this parameter equals False.

See Also

TSTCabReader.Options
TSTCabWriter.AddFile


OnCopyFile event (TSTCabReader component)

Occurs before file extracting.

Syntax

type
   TSTCabReaderCopyFileEvent = procedure(
      Sender: TSTCabReader;
      const aSrcFileName: String; anUncompressedSize: Longint;
      aDate, aTime, anAttrs, aFolderNo: USHORT;
      var aDstFullFileName: String;
      var anAbort: Boolean) of object;

property OnCopyFile: TSTCabReaderCopyFileEvent;

Parameters

Sender
Object whose event handler is called.
aSrcFileName
Name of a file in the cabinet.
anUncompressedSize
Uncompressed size of the file.
aDate
File's 16-bit FAT date.
aTime
File's 16-bit FAT time.
anAttrs
File's 16-bit FAT attributes.
aFolderNo
Folder number where the file lies.
aDstFullFileName
Name of the file where it will be extracted. Upon entry into the handler, this parameter equals default file name. Set to empty string to skip extracting this file or set to needed file name.
anAbort
Abort extracting. Upon entry into the handler, this parameter equals False.

Remarks

Usually this event used for selecting which files need to extract and which files don't need to extract.


OnCopyPartialFile event (TSTCabReader component)

Occurs on extracting file which is a continuation from previous cabinet.

Syntax

type
   TSTCabReaderCopyPartialFileEvent = procedure(
      Sender: TSTCabReader;
      const aSrcFileName, aStartCabName,
      aStartDiskName, aDstFullFileName: String;
      var anAbort: Boolean) of object;

property OnCopyPartialFile: TSTCabReaderCopyPartialFileEvent;

Parameters

Sender
Object whose event handler is called.
aSrcFileName
Name of a file in the cabinet.
aStartCabName
Name of the cabinet on which the first segment of the file exists.
aStartDiskName
Name of the disk on which the first segment of the file exists.
aDstFullFileName
Name of the file where it is extracting. Can be empty due some cause!
anAbort
Abort extracting. Upon entry into the handler, this parameter equals False.


OnNextCabinet event (TSTCabReader component)

Occurs when extracted file continued on next cabinet.

Syntax

type
   TSTCabReaderNextCabinetEvent = procedure(
      Sender: TSTCabReader;
      const aCabName, aDiskName: String;
      var aCabPath: String;
      anError: TFDIERROR;
      var anAbort: Boolean) of object;

property OnNextCabinet: TSTCabReaderNextCabinetEvent;

Parameters

Sender
Object whose event handler is called.
aCabName
Name of the next cabinet on which the current file is continued.
aDiskName
Name of the next disk on which the current file is continued.
aCabPath
Cabinet path. You can change this parameter.
anError
Equals success or error value.
anAbort
Abort extracting. Upon entry into the handler, this parameter equals False.

Remarks

This event is called only when extracted file is continued in a subsequent cabinet.


OnUnrecognizedNotify event (TSTCabReader component)

Occurs on unrecognized notification from FDI during extracting.

Syntax

type
   TSTCabReaderUnrecognizedNotifyEvent = procedure(
      Sender: TSTCabReader;
      aNotifyType: TFDINOTIFICATIONTYPE;
      var aNotify: TFDINOTIFICATION;
      var aResult: Integer) of object;

property OnUnrecognizedNotify: TSTCabReaderUnrecognizedNotifyEvent;

Parameters

Sender
Object whose event handler is called.
aNotifyType
Type of the notification.
aNotify
Notification parameters.
aResult
Reaction on this notification. Upon entry into the handler, this parameter equals 0.

Remarks

Set aResult to -1 to abort extracting or leave it equals 0 to continue.

See Also

TFDINOTIFICATION


Options property (TSTCabReader component)

Defines options.

Syntax

type
   TSTCabReaderOption = (
      croExecuteOnExtract,
      croDontOverwriteReadOnlyFiles
   );
   TSTCabReaderOptions = set of TSTCabReaderOption;

   property Options: TSTCabReaderOptions;

Remarks

The croExecuteOnExtract specifies whether the files marked for executing should be executed automatically on cabinet extracting or not.

The croDontOverwriteReadOnlyFiles specifies whether overwrite read-only files or skip them.

See Also

TSTCabReader.OnCloseFile


AddFile method (TSTCabWriter component)

Compress a single file to an archive.

Syntax

procedure AddFile(
   const aSrcFileName, aDstFileName: String;
   anOptions: TSTCabAddFileOptions = []);

Parameters

aSrcFileName
The name of the compressed file.
aDstFileName
The name under which file will be placed in archive. If you want organize archived files in subfolders then place subfolders names before file name. Example: data\jan.dat.
anOptions
File storing options.

Remarks

Before compressing set necessary compressing type.

See Also

TSTCabAddFileOptions
TSTCabWriter.AddFiles
TSTCabWriter.CompressionType
TSTCabWriter.CompressionLzxLevel
TSTCabWriter.OnBeforeFileAdd


AddFiles method (TSTCabWriter component)

Compress files that match a mask to an archive.

Syntax

procedure AddFiles(
   const aSrcPath, aDstPath: String;
   anOptions: TSTCabAddFilesOptions = []);

Parameters

aSrcPath
Specifies a path and file name, which can contain wildcard characters (* and ?). You cannot give only path. Files mask is required.
aDstPath
An archive subfolder name where files will be placed. For root subfolder give empty string.
anOptions
File processing options. For processing subfolders give cafsoRecurseSubdirs.

Remarks

Before compressing set necessary compressing type.

See Also

TSTCabAddFilesOptions
TSTCabWriter.AddFile
TSTCabWriter.CompressionType
TSTCabWriter.CompressionLzxLevel
TSTCabWriter.OnBeforeFileAdd


CabinetFileCountThreshold property (TSTCabWriter component)

Threshold for the number of files to store in a CAB file.

Syntax

property CabinetFileCountThreshold: ULONG default 0;

Remarks

Once this count has been reached the current CAB file will be closed and a new CAB file will be started. Specify 0 for unlimited number of files.

See Also

TSTCabWriter.CabinetSizeThreshold


CabinetNameTemplate property (TSTCabWriter component)

Template for CAB files names.

Syntax

property CabinetNameTemplate: String;

Remarks

The wildcard character (*) in this template is replaced by the CAB file number (0, 1, etc.). First CAB file has a name that was given to Open method.

If CabinetNameTemplate is an empty string then as template is taken a file name that was given to Open method with added * at the end.

See Also

TSTCabWriter.CabinetPathTemplate
TSTCabWriter.DiskLabelTemplate


CabinetPathTemplate property (TSTCabWriter component)

Template for CAB files pathes.

Syntax

property CabinetPathTemplate: String;

Remarks

The wildcard character (*) in this template is replaced by the disk number (1, 2, etc.). First CAB file has a path that was given to Open method.

If CabinetPathTemplate is an empty string then as template is taken a file path that was given to Open method.

See Also

TSTCabWriter.CabinetNameTemplate
 TSTCabWriter.DiskLabelTemplate


CabinetSizeThreshold property (TSTCabWriter component)

Threshold size for a CAB file.

Syntax

property CabinetSizeThreshold: ULONG default 0;

Remarks

Once this size has been reached the current CAB file will be closed and a new CAB file will be started. Specify 0 for unlimited size.

See Also

TSTCabWriter.CabinetFileCountThreshold


Close method (TSTCabWriter component)

Close a CAB file.

Syntax

procedure Close(aFlushCab: Boolean = True);

Parameters

aFlushCab
True for commit CAB file. False for discard it.

Remarks

After compressing files to an archive, you need to close an archive.

See Also

TSTCabWriter.Open


CompressionLzxLevel property (TSTCabWriter component)

Level of LZX compression.

Syntax

property CompressionLzxLevel: TSTCabLzxLevel default 21;

Remarks

Higher level gives more compression ratio, but requires more time.

See Also

TSTCabLzxLevel
 TSTCabWriter.CompressionType


CompressionType property (TSTCabWriter component)

Type of compression method.

Syntax

property CompressionType: TSTCabCompressionType default cctLzx;

Remarks

LZX compression method can archive higher compressions ratios than MSZIP. LZX compression requires more time, but LZX decompression is typically faster.

See Also

TSTCabCompressionType

TSTCabWriter.CompressionLzxLevel


DiskLabelTemplate property (TSTCabWriter component)

Template for disk labels of CAB files.

Syntax

property DiskLabelTemplate: String;

Remarks

The wildcard character (*) in this template is replaced by the disk number (1, 2, etc.).

If DiskLabelTemplate is an empty string then as template is taken standard label "Disk*".

See Also

TSTCabWriter.CabinetNameTemplate
 TSTCabWriter.CabinetPathTemplate


FileName property (TSTCabWriter component)

Full file name of an archive.

Syntax

property FileName: String;

Remarks

This property has meaning value only after Open method.

See Also

TSTCabWriter.Open


FolderFileCountThreshold property (TSTCabWriter component)

Threshold for the number of files to store in a folder.

Syntax

property FolderFileCountThreshold: ULONG default 0;

Remarks

Once this count has been reached the current folder will be closed and a new folder will be started. Specify 0 for unlimited number of files.

See Also

TSTCabWriter.FolderSizeThreshold


FolderSizeThreshold property (TSTCabWriter component)

FolderSizeThreshold component (TSTCabWriter component)

Threshold size for a folder.

Syntax

property FolderSizeThreshold: ULONG default 0;

Remarks

Once this size has been reached the current cabinet will be closed and a new cabinet will be started. Specify 0 for unlimited size.

See Also

TSTCabWriter.FolderFileCountThreshold


Handle property (TSTCabWriter component)

FCI context handle.

Syntax

property Handle: HFCI;

Remarks

Read-Only. Usually you don't use it.


OnBeforeFileAdd event (TSTCabWriter component)

Occurs just before adding a file to a cabinet.

Syntax

type
   TSTCabWriterBeforeFileAddEvent = procedure(
      Sender: TSTCabWriter;
      const aFileName: String;
      var aSkip: Boolean) of object;

property OnBeforeFileAdd: TSTCabWriterBeforeFileAddEvent;

Parameters

Sender
Object whose event handler is called.
aFileName
The name of the file which will be added.
aSkip
Skip the file. Upon entry into the handler, this parameter equals False.

See Also

TSTCabWriter.AddFile
TSTCabWriter.AddFiles


OnCabinetStatus event (TSTCabWriter component)

Occurs when a cabinet has been writed out on a hard disk.

Syntax

type
   TSTCabWriterCabinetStatusEvent = procedure(
      Sender: TSTCabWriter;
      aPrevEstimatedSize, anActualSize: ULONG;
      var aDesiredSize: ULONG;
      var anAbort: Boolean) of object;

property OnCabinetStatus: TSTCabWriterCabinetStatusEvent;

Parameters

Sender
Object whose event handler is called.
aPrevEstimatedSize
The estimated size of the previous cabinet.
anActualSize
The actual resulting cabinet size.
aDesiredSize
The desired size of the next cabinet. Upon entry into the handler, this parameter equals 0. Leave it or set equals to anActualSize, or possibly a value rounded up to slightly higher than that.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.


OnFilePlaced event (TSTCabWriter component)

Occurs whenever the location of a file or file segment on a particular cabinet has been finalized.

Syntax

type
   TSTCabWriterFilePlacedEvent = procedure(
      Sender: TSTCabWriter;
      const aCCab: TCCAB;
      const aFileName: String;
      aFileSize: Longint;
      aContinuation: Boolean;
      var anAbort: Boolean) of object;

property OnFilePlaced: TSTCabWriterFilePlacedEvent;

Parameters

Sender
Object whose event handler is called.
aCCAB
The CCAB structure of the cabinet on which the file has been stored.
aFileName
The file name of the file which has been placed.
aFileSize
The file size.
aContinuation
Signifies whether the file is a later segment of a file which has been split across cabinets.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.

See Also

TCCAB


OnFileStatus event (TSTCabWriter component)

Occurs when following data blocks of a file have been compressed into a folder.

Syntax

type
   TSTCabWriterFileStatusEvent = procedure(
      Sender: TSTCabWriter;
      aCompressedBlockSize, anUncompressedBlockSize: ULONG;
      var anAbort: Boolean) of object;

property OnFileStatus: TSTCabWriterFileStatusEvent;

Parameters

Sender
Object whose event handler is called.
aCompressedBlockSize
Is either zero or the compressed size of the most recently compressed block.
anUncompressedBlockSize
Is either zero or the uncompressed size of the most recently readed block.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.


OnFolderStatus event (TSTCabWriter component)

Occurs when a folder has been copied to a cabinet.

Syntax

type
   TSTCabWriterFolderStatusEvent = procedure(
      Sender: TSTCabWriter;
      aCopiedSize, aTotalSize: ULONG;
      var anAbort: Boolean) of object;

property OnFolderStatus: TSTCabWriterFolderStatusEvent;

Parameters

Sender
Object whose event handler is called.
aCopiedSize
The amount copied size.
aTotalSize
The total size of the folder.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.


OnGetNextCabinet event (TSTCabWriter component)

Occurs whenever cabinet size or stored file count reached thresholds.

Syntax

type
   TSTCabWriterGetNextCabinetEvent = procedure(
      Sender: TSTCabWriter;
      var aCCab: TCCAB;
      aPrevCabSize: ULONG;
      var anAbort: Boolean) of object;

property OnGetNextCabinet: TSTCabWriterGetNextCabinetEvent;

Parameters

Sender
Object whose event handler is called.
aCCAB
The CCAB structure of the cabinet which has just been completed. However, the iCab and iDisk fields will have been incremented by one. Also szDisk, szCab and szCabPath will have been prepared by templates for the next cabinet. You can change these fields and similarly etc. parameters may also be modified.
aPrevCabSize
An estimate of the size of the cabinet which has just been completed.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.

See Also

TCCAB
TSTCabWriter.CabinetSizeThreshold
TSTCabWriter.CabinetFileCountThreshold


OnProgress event (TSTCabWriter component)

Occurs periodically during compressing files to a cabinet.

Syntax

type
   TSTCabWriterProgressEvent = procedure(
      Sender: TSTCabWriter;
      var anAbort: Boolean) of object;

property OnProgress: TSTCabWriterProgressEvent;

Parameters

Sender
Object whose event handler is called.
anAbort
Abort compressing. Upon entry into the handler, this parameter equals False.


Open method (TSTCabWriter component)

Open a new CAB file.

Syntax

procedure Open(const aFileName: String);

Parameters

aFileName
The name of a new CAB file.

Remarks

Before compressing files to an archive, you need to open an archive.

See Also

TSTCabWriter.Close


ReservePerCabinetSize property (TSTCabWriter component)

Amount of additional space to reserve for the cabinet.

Syntax

property ReservePerCabinetSize: UINT default 0;

Remarks

Value must be multiple of 4 and lies between 0 and 60000.

Value 6144 is commonly used to reserve a 6K space in the cabinet file as needed for codesigning

See Also

TSTCabWriter.ReservePerFolderSize

TSTCabWriter.ReservePerDataSize


ReservePerDataSize property (TSTCabWriter component)

Amount of additional space to reserve for each data block in the cabinet.

Syntax

property ReservePerDataSize: UINT default 0;

Remarks

Value must be multiple of 4 and lies between 0 and 255.

See Also

TSTCabWriter.ReservePerCabinetSize

TSTCabWriter.ReservePerFolderSize


ReservePerFolderSize property (TSTCabWriter component)

Amount of additional space to reserve for each folder in the cabinet.

Syntax

property ReservePerFolderSize: UINT default 0;

Remarks

Value must be multiple of 4 and lies between 0 and 255.

See Also

TSTCabWriter.ReservePerCabinetSize

TSTCabWriter.ReservePerDataSize


SetID property (TSTCabWriter component)

Identificator of the cabinet.

Syntax

property SetID: USHORT default 0;

Remarks

Can be any value. All splited cabinet files have the same identificator.


StartNewCabinet method (TSTCabWriter component)

Start a new cabinet.

Syntax

procedure StartNewCabinet;

Remarks

Close the current cabinet and start a new cabinet.

See Also

TSTCabWriter.StartNewFolder


StartNewFolder method (TSTCabWriter component)

Start a new folder.

Syntax

procedure StartNewFolder;

Remarks

Close the current folder and start a new folder.

See Also

TSTCabWriter.StartNewCabinet