Unit Cabinet

++ c a b i n e t . p a s Copyright (c) 1997 by Alexander Staubo, all rights reserved. Abstract: Class framework wrapping around the Microsoft Cabinet SDK FCI and FDI interfaces. Known issues: - Stream errors are not converted to error codes. Error handling in default file handler/sevent handlers is strictly rudimentary. Exceptions are raised upon API errors and are not handled responsibly. - Only one TCabinetReader instance can be active at any time, due to a sordid little limitation in the FDI API. - fdintENUMERATE notification message is not handled in this version. - Error codes in exceptions are not expanded into descriptive strings. About event handlers: The default event handlers of TCabinetReader and TCabinetWriter lessen the work of performing common CAB ops for file-system-based cabinets, but assume file handles are Win32 file handles; so they are incompatible with non-file cabinet file handlers by default. This behaviour is controlled by the FileSupport property of either object; turning this off disables the file-handle support. For more information, see the component declarations below. The default implementation of OnGetTempFile uses the first three characters in the module file name for the temporary file name. Revision history: 26/12/1997 02:57 alexs 1.0 Initial release --

Classes

ECabinetError - Exceptions
TCabinetFileHandler - Classes } { TCabinetFileHandler abstract class -- represents a cabinet-associated file handler.
TCabinetInterface - TCabinetInterface base class -- abstract cabinet interface.
TCabinetReader - TCabinetReader class -- for decompressing files from an existing cabinet file Open Opens a cabinet for reading.
TCabinetWriter - TCabinetWriter class -- for compressing files into a new cabinet file DoFileStatus DoFolderStatus DoCabinetStatus DoGetNextCabinet DoFilePlaced DoGetTempFile DoGetOpenInfo The virtual equivalents of their respective event handlers (OnFileStatus etc.
TStreamCabinetFileHandler - TStreamCabinetFileHandler class -- uses a collection of streams for handling file access.

Functions

CheckErf -
MakeLzxCompression -
MakeMsZipCompression -
MakeNoCompression - Function declarations

Functions
RaiseCabinetError -
Register - Registration

Types

TAddFileOption
TAddFileOptions
TCabinetInfoEvent
TCabinetStatusEvent
TCloseCopiedFileEvent
TCompressionParameters
TCompressionType
TCopyFileEvent
TCpuType
TFileCopyAction
TFilePlacedEvent
TFileStatusEvent
TFileType
TFolderStatusEvent
TGetNextCabinetEvent
TGetOpenInfoEvent
TGetTempFileEvent
TNextCabinetEvent
TPartialFileEvent

Constants

Variables


Functions


procedure CheckErf (Erf : TERF);


function MakeLzxCompression (Level : Integer) : TCompressionParameters;


function MakeMsZipCompression : TCompressionParameters;


function MakeNoCompression : TCompressionParameters;

Function declarations

Functions


procedure RaiseCabinetError (ErrorCode, ErrorType : Integer);


procedure Register;

Registration

Types


TAddFileOption =
    (
      afoExecuteOnExtract
    );
Options for adding files
TAddFileOptions = set of TAddFileOption

TCabinetInfoEvent = procedure (Sender : TObject; const CabinetName,
    CabinetDisk, CabinetPath : string; SetId, CabinetNumber : Longint;
    var Abort : Boolean) of object
Reader events
TCabinetStatusEvent = procedure (Sender : TObject; PreEstimatedSize,
    ActualSize : Longint; var WantedSize : Longint) of object

TCloseCopiedFileEvent = procedure (Sender : TObject; const FileName : string;
    FileHandle : Integer; Date, Time, Attribs : Smallint;
    FolderIndex : Integer; Execute : Boolean; var Abort : Boolean) of object

TCompressionParameters = record
Compression : TCompressionType;
LzxLevel : 15..21;
QuantumLevel : 1..7;
QuantumMemory : 10..21;
end;
Parameters for compression
TCompressionType =
    (
      ctNone,
      ctMsZip,
      ctQuantum,
      ctLzx
    );
Compression type
TCopyFileEvent = procedure (Sender : TObject; const FileName : string;
    UncompressedSize : Longint; Date, Time, Attribs : Smallint;
    var Action : TFileCopyAction; var DestFileHandle : Integer) of object

TCpuType =
    (
      cptAuto,
      cpt80286,
      cpt80386
    );
CPU type for use in decompression
TFileCopyAction =
    (
      fcaAbort,
      fcaSkip,
      fcaCopy,
      fcaDefaultCopy
    );
Action to take when copying file
TFilePlacedEvent = procedure (Sender : TObject; var CabParameters : TCCAB;
    const FileName : string; FileLength : Longint; Continuation : Boolean;
    var AbortProcessing : Boolean) of object

TFileStatusEvent = procedure (Sender : TObject; CompressedSize,
    UncompressedSize : Longint; var ResultCode : Integer) of object
Writer events
TFileType =
    (
      ftCabinet,
      ftSource,
      ftDestination
    );
File type
TFolderStatusEvent = procedure (Sender : TObject; SizeCopied,
    TotalSize : Longint; var ResultCode : Integer) of object

TGetNextCabinetEvent = procedure (Sender : TObject;
    var CabParameters : TCCAB; var NewCabFileName : string;
    PreviousCabEstimatedSize : Longint; var AbortCreation : Boolean) of object

TGetOpenInfoEvent = procedure (Sender : TObject; const FileName : string;
    var Date, Time, Attributes : Smallint; var FileHandle,
    ResultCode : Longint) of object

TGetTempFileEvent = procedure (Sender : TObject; var TempFileName : string; 
    var Success : Boolean) of object

TNextCabinetEvent = procedure (Sender : TObject; const NextCabinetName,
    NextCabinetDisk : string; var CabinetPath : string;
    ErrorIndication : TFDIERROR; var Abort : Boolean) of object

TPartialFileEvent = procedure (Sender : TObject; const FileName,
    FirstCabinetName, FirstCabinetDisk : string;
    var Abort : Boolean) of object

Constants


Variables