Unit AFCUnzip

Classes

Functions

ChfUnzip_Init - uncompressed and compressed zip size usage: SourceZipFile = the zip file Compressed = the compressed size of the files in the archive Returns: the uncompressed size of the ZIP archive e.
CloseZipFile - VERY simple test for zip file e.
FileUnzip - ********************************************************************} {**********************************************************************} {****** HIGH LEVEL FUNCTIONS: BY THE AFRICAN CHIEF ********************} {**********************************************************************} {

Matches } {
FileUnzipEx - high level unzip usage: SourceZipFile: source zip file; TargetDirectory: target directory FileSpecs: "*.
GetFirstInZip - usage: in_name: name of zip file with full path out_name: desired name for out file offset: header position of desired file in zipfile hFileAction: handle to dialog box showing advance of decompression (optional) cm_index: notification code sent in a wm_command message to the dialog to update percent-bar Return value: one of the above unzip_xxx codes Example for handling the cm_index message in a progress dialog: unzipfile(.
GetNextInZip - Get first entry from ZIP file e.
GetSupportedMethods - initialise or reinitialise the shared data: !!! use with care !!! {**********************************************************************} {**********************************************************************} {************ LOW LEVEL FUNCTIONS: BY CHRISTIAN GHISLER ***************} {**********************************************************************} {

**************************************************************************) {
IsZip - Get next entry from ZIP file e.
SetUnZipQuestionProc - sets the internal unzip report procedure to aproc Returns: pointer to the original report procedure (return value should normally be ignored) e.
SetUnZipReportProc - view contents of zip file usage: SourceZipFile: source zip file; FileSpecs: "*.
UnzipFile - Checks which pack methods are supported by the dll} {bit 8=1 -> Format 8 supported, etc.
UnzipSize - sets the internal unzip question procedure to aproc Returns: pointer to the original "question" procedure (return value should normally be ignored) e.
ViewZip - high level unzip with no callback parameters; passes ZipReport & ZipQuestion internally, so you can use SetZipReportProc and SetZipQuestionProc before calling this; e.

Types

Constants

Variables


Functions


PROCEDURE ChfUnzip_Init;

uncompressed and compressed zip size usage: SourceZipFile = the zip file Compressed = the compressed size of the files in the archive Returns: the uncompressed size of the ZIP archive e.g., Var Size,CSize:longint; begin Size := UnzipSize('test.zip', CSize); end;

SetUnZipQuestionProc } {***************************************************************************} {***************************************************************************} {


PROCEDURE CloseZipFile ( VAR Zprec : tZiprec );

VERY simple test for zip file e.g., ItsaZipFile := IsZip('test.zip');

************** free ZIP buffers


FUNCTION FileUnzip ( SourceZipFile, TargetDirectory, FileSpecs : pChar; Report : UnzipReportProc;Question : UnzipQuestionProc ) : integer;

********************************************************************} {**********************************************************************} {****** HIGH LEVEL FUNCTIONS: BY THE AFRICAN CHIEF ********************} {**********************************************************************} {

Matches } {


FUNCTION FileUnzipEx ( SourceZipFile, TargetDirectory, FileSpecs : pChar ) : integer;

high level unzip usage: SourceZipFile: source zip file; TargetDirectory: target directory FileSpecs: "*.*", etc. Report: Report callback or Nil; Question: Question callback (for confirmation of whether to replace existing files) or Nil; * REFER to ZIPTYPES.PAS for information on callback functions e.g., Count := FileUnzip('test.zip', 'c:\temp', '*.*', MyReportProc, Nil);

FileUnzip } {


FUNCTION GetFirstInZip ( zipfilename : pchar;VAR zprec : tZipRec ) : integer;

usage: in_name: name of zip file with full path out_name: desired name for out file offset: header position of desired file in zipfile hFileAction: handle to dialog box showing advance of decompression (optional) cm_index: notification code sent in a wm_command message to the dialog to update percent-bar Return value: one of the above unzip_xxx codes Example for handling the cm_index message in a progress dialog: unzipfile(......,cm_showpercent); ... procedure TFileActionDialog.wmcommand(var msg:tmessage); var ppercent:^word; begin TDialog.WMCommand(msg); if msg.wparam=cm_showpercent then begin ppercent:=pointer(lparam); if ppercent<>nil then begin if (ppercent^>=0) and (ppercent^<=100) then SetProgressBar(ppercent^); if UserPressedAbort then ppercent^:=$ffff else ppercent^:=0; end; end; end; end;

************** Get first entry from ZIP file


FUNCTION GetNextInZip ( VAR Zprec : tZiprec ) : integer;

Get first entry from ZIP file e.g., rc:=GetFirstInZip('test.zip', myZipRec);

************** Get next entry from ZIP file


FUNCTION GetSupportedMethods : longint;

initialise or reinitialise the shared data: !!! use with care !!! {**********************************************************************} {**********************************************************************} {************ LOW LEVEL FUNCTIONS: BY CHRISTIAN GHISLER ***************} {**********************************************************************} {

**************************************************************************) {


FUNCTION IsZip ( filename : pchar ) : boolean;

Get next entry from ZIP file e.g., rc:=GetNextInZip(myZipRec);

************** VERY simple test for zip file


FUNCTION SetUnZipQuestionProc ( aProc : UnzipQuestionProc ) : Pointer;

sets the internal unzip report procedure to aproc Returns: pointer to the original report procedure (return value should normally be ignored) e.g., SetUnZipReportProc(MyReportProc);

SetUnZipReportProc } {


FUNCTION SetUnZipReportProc ( aProc : UnzipReportProc ) : Pointer;

view contents of zip file usage: SourceZipFile: source zip file; FileSpecs: "*.*", etc. Report: callback procedure to process the reported contents of ZIP file; * REFER to ZIPTYPES.PAS for information on callback functions e.g., ViewZip('test.zip', '*.*', MyReportProc);

UnZipSize } {


FUNCTION UnzipFile ( in_name : pchar;out_name : pchar;offset : longint;hFileAction : word;cm_index : integer ) : integer;

Checks which pack methods are supported by the dll} {bit 8=1 -> Format 8 supported, etc.

****************** main low level function: unzipfile ********************} {written and not copyrighted by Christian Ghisler


FUNCTION UnzipSize ( SourceZipFile : pChar;VAR Compressed : Longint ) : longint;

sets the internal unzip question procedure to aproc Returns: pointer to the original "question" procedure (return value should normally be ignored) e.g., SetUnZipQuestionProc(QueryFileExistProc);

ViewZip } {


FUNCTION ViewZip ( SourceZipFile, FileSpecs : pChar; Report : UnzipReportProc ) : integer;

high level unzip with no callback parameters; passes ZipReport & ZipQuestion internally, so you can use SetZipReportProc and SetZipQuestionProc before calling this; e.g., Count := FileUnzipEx('test.zip', 'c:\temp', '*.*');

FileUnzipEx } {


Types


Constants


Variables