Unit ChiefLZ

CHIEFLZ UNIT/DLL, by Dr A Olowofoyeku (the African Chief); internet: laa12@cc.keele.ac.uk http://ourworld.compuserve.com/homepages/African_Chief/chief.htm Version 1.00. USES the original LZSSUNIT source, as amended by the Chief, and Chris J Rankin. Ported to Win32 (Delphi 2.0) by Chris Rankin. // -----------------------------------------------------------// * 16-bit ASM functions converted to 32-bit ASM by Chris J Rankin * Win32 (Delphi 2.0) code: added by Chris J Rankin Package assembled together: 5th September 1996. The routines in this package are already being used in some famous programs! {----------------------------------------------------------------------} {to compile to a DLL in Delphi you need to rename this with the extension .DPR} {$I LZDefine.inc} {// defines various things, including "aDLL" //

Classes

Functions

Compress - point to function to ask question if the target file exists already - if nothing is set, then existing target files will be overwritten automatically} {$endif
Decompress - compress the source file >> target file
Done - you can init with source and target file names, or with blanks - so set the source and target file names later
GetChiefLZArchiveInfo - if LZ file then return uncompressed size - else return actual filesize.
GetChiefLZArchiveSize - if LZ-Archive then this function returns True, with the header info in Header.
GetChiefLZFileName - is this an LZ archive file compressed with this unit?

/////////////////////////////////////////////////////////} {$ifdef Win32
GetChiefLZFileSize - if LZ file, then return name (in dest, if not Win32) - else return fname (in dest, if not Win32)

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////
GetFullLZName - decompress the file aName, obtaining the output name from the header automatically If target file exists, and autoreplace=false then the function exits and returns -100 else the target file will be overwritten

/////////////////////////////////////////////////////////
IsChiefLZArchive - De-Arc a ChiefLZ archive

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////} These are the LZ functions exported from the unit {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////
IsChiefLZFile - This functione is used for decompression.
LZArchive - is this an LZ file compressed with this unit?

/////////////////////////////////////////////////////////
LZCompress - ////////////////////////////////////////////////////} {////////////////////////////////////////////////////} {exported INTERFACE functions} {$ifNDef aDLL

/////////////////////////////////////////////////////////
LZCompressEx - If ArchName is LZArchive, returns sum of uncompressed file-sizes in archive.
LZDearchive - archive all the files matching "fSpec" into archive "ArchName"; fSpec = a filespec (e.
LZDecompress - This Function is used for compression.
LZDecompressEx - compress the file aName, and use the filename, with the last character replaced by a '~' as the output file If target file exists, and autoreplace=false then the function exits and returns -100 else the target file will be overwritten

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////
SetInputName -
SetOutputName - set source file name; absolutely necessary
SetQuestionProc - point to procedure to report progress
SetReportProc - set target file name = if empty, then a default one will be used

Types

LZObj

Constants

ChiefLZVersionNumber

Variables

MyLZMarker


Functions


Function Compress: Longint;

point to function to ask question if the target file exists already - if nothing is set, then existing target files will be overwritten automatically} {$endif

Function Decompress: Longint;

compress the source file >> target file

Destructor Done;

you can init with source and target file names, or with blanks - so set the source and target file names later

function GetChiefLZArchiveInfo(const ArchName: {$ifdef Win32} string ; var Header: TChiefLZArchiveHeader): boolean;

if LZ file then return uncompressed size - else return actual filesize. On error, Win32 throws exception; Win16 returns -1

/////////////////////////////////////////////////////////


Function GetChiefLZArchiveSize(const ArchName: {$ifdef Win32} string ): LongInt;

if LZ-Archive then this function returns True, with the header info in Header. Otherwise the function returns False

/////////////////////////////////////////////////////////


Function GetChiefLZFileName{$ifdef Win32}(const fName: string): string;

is this an LZ archive file compressed with this unit?

/////////////////////////////////////////////////////////} {$ifdef Win32


Function GetChiefLZFileSize(fName: {$ifdef Win32} string ): LongInt;

if LZ file, then return name (in dest, if not Win32) - else return fname (in dest, if not Win32)

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


function GetFullLZName(Const X : TChiefLZArchiveHeader; Index: Integer): String;

decompress the file aName, obtaining the output name from the header automatically If target file exists, and autoreplace=false then the function exits and returns -100 else the target file will be overwritten

/////////////////////////////////////////////////////////


Function IsChiefLZArchive(const fName: {$ifdef Win32} string ): boolean;

De-Arc a ChiefLZ archive

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////} These are the LZ functions exported from the unit {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


Function IsChiefLZFile(const fName: {$ifdef Win32} string ): boolean;

This functione is used for decompression. Source = Source file name Dest = target file name LZQuestion = procedural type to ask for overwrite permission aProc = procedural type to return progress information

LZDecompress } {/////////////////////////////////////////////////////////


Function LZArchive(const fSpec, ArchName: {$ifdef Win32} string ; LZRecurseDirs: TLZRecurse; aProc: TLZReportProc): LongInt;

is this an LZ file compressed with this unit?

/////////////////////////////////////////////////////////


Function LZCompress(const {$ifdef Win32} Source, Dest: string ; LZQuestion: TLZQuestionFunc; aProc: TLZReportProc):LongInt;

////////////////////////////////////////////////////} {////////////////////////////////////////////////////} {exported INTERFACE functions} {$ifNDef aDLL

/////////////////////////////////////////////////////////


Function LZCompressEx(const {$ifdef Win32} Name: string ; ReplaceQuestion: TLZQuestionFunc; aProc: TLZReportProc): LongInt;

If ArchName is LZArchive, returns sum of uncompressed file-sizes in archive. If not LZArchive then returns size of file ArchName

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


Function LZDearchive(ArchName: {$ifdef Win32} string ; {$ifdef Win32} DefDir: string ; LZQuestion: TLZQuestionFunc; aProc: TLZReportProc; aRename: TLZRenameFunc): LongInt;

archive all the files matching "fSpec" into archive "ArchName"; fSpec = a filespec (e.g., "*.PAS", or a filename containing a list of files to be archived - in which case, use "/F=" as the fSpec. LZRecurseDirs = whether to recurse into subdirectories for matching files

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


Function LZDecompress({$ifdef Win32} Source, Dest: string ; LZQuestion: TLZQuestionFunc; aProc: TLZReportProc):LongInt;

This Function is used for compression. Source = Source file name Dest = target file name LZQuestion = procedural type to ask for overwrite permission aProc = procedural type to return progress information

LZCompress } {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


Function LZDecompressEx({$ifdef Win32} Name: string ; ReplaceQuestion: TLZQuestionFunc; aProc: TLZReportProc): LongInt;

compress the file aName, and use the filename, with the last character replaced by a '~' as the output file If target file exists, and autoreplace=false then the function exits and returns -100 else the target file will be overwritten

/////////////////////////////////////////////////////////} {/////////////////////////////////////////////////////////


Procedure SetInputName(Const aName: String);


Procedure SetOutputName(Const aName: String);

set source file name; absolutely necessary

Procedure SetQuestionProc(const aProc: TLZQuestionFunc);

point to procedure to report progress

Procedure SetReportProc(const aProc: TLZReportProc);

set target file name = if empty, then a default one will be used

Types


LZObj=                                  Object{$Endif Delphi}
   Constructor                       
                               Init
               {$endif}(Const InfName, OutFName:String)
last char in filenames created automatically} {////////////////////////////////////////////////////} {////////////////////////////////////////////////////} {////////////////////////////////////////////////////} {Pascal object encapsulating the functionality of this unit - CANNOT BE EXPORTED BY DLL} {////////////////////////////////////////////////////} {////////////////////////////////////////////////////} {$ifndef aDLL

Constants

ChiefLZVersionNumber = 100

------------------------------------------------------------} {$ifNDef aDLL

Variables

MyLZMarker : Char = '~'

version 1.00 } {$ifdef Win32