ZIPProvider Object

The ZIPProvider object is the general purpose PKZIP services object used by the Visual Tools for ZIP file composition and extraction. You can use this object in your VTOM scripts for low-level PKZIP operations from within the Visual Tools. Because Macromedia uses a licensed control for its ZIP operations, you cannot use ZIPProvider outside of the Visual Tools.

Properties

CompressionLevel

Syntax

CompressionLevel: Integer 

Description

Sets and gets the compression level use to compress the archive file. You can set the value from 0 to 9; 0 represents no compression, 1 is fastest compression, and 9 is the slowest but most size-efficient compression.

ExtractionDir

Syntax

ExtractionDir: OleVariant 

Description

Sets and gets the directory path where the files are extracted from an existing archive file using the Extract method.

FileCount

Syntax

FileCount: Integer (read-only) 

Description

The number of elements in the archive.

Overwrite

Syntax

Overwrite: WordBool  

Description

Boolean. Sets and gets whether the newly extracted files overwrite any existing file in the ExtractionDir directory.

Password

Syntax

Password: OleVariant

Description

Sets/gets the password for the archive file. Set this property when extracting password protected files or to passwor- protect files in an archive file that you just created.

ZIPComment

Syntax

ZIPComment: OleVariant

Description

Sets and gets the comment for the archive file. Use this property to read a comment of an existing archive file, or set the comment for a new archive file that you created.

ZIPFile

Syntax

ZIPFile: OleVariant

Description

Sets and gets the archive file path against which the operation is to be applied. To create a new archive file set this property to the file path of the new file and then call the Add method to populate the file with content. To add, delete, or extract files from an existing archive file, set the property to the file path of the file and call Add, Delete, or Extract methods on the file.

Example

Sample ZIPFile script

//***********************************************//
// The following example uses the ZIPFile property to extract a file
// (somefile.exe) from another file (d:\\downloads\\test.zip): 
//************************************************//
function Main () {
  var hsOKInfo = 64; 
  var app = Application; 
  var ZIPPro = app.ZIPProvider;
  ZIPPro.ExtractionDir = 'd:\\ExtractHere\\'; ZIPPro.ZipFile =
    'd:\\downloads\\test.zip'; 
  var ResultCode = ZIPPro.Extract('somefile.exe'); 
  app.MessageBox( "Return Code :" + ResultCode ,"ZIPProvider",
    hsOKInfo); 
} 

Methods

Add

Syntax

Add(Files: OleVariant; bRecurse, bIncludeDirs, bIncludeHiddenFiles, bIn-cludeVolumeLabels: WordBool): Integer;  

Description

Boolean. Adds files to an archive. Use the Files parameter to narrow down the group of files to add. You can specify a single file, a set of files delimited by line breaks, or an entire directory using wildcards. Use the bRecurse parameter to add subfolders. Use bIncludeDirs to specify whether directory information should be stored in the archive. Use bIncludeHiddenFiles and bIncludeVolumeLabels to restrict the inclusion of hidden files or volume labels. Do not set the bIncludeVolumeLabels parameter to True unless you specify the drive letter as the first element in the Files parameter. The Files parameter may contain multiple elements separated by line breaks. The function returns a status code that can be investigated to determine the success of the operation.

Example

Sample Add script

function Main () {   
  var hsOKInfo = 64; 
  var app = Application; 
  var ZIPPro = app.ZIPProvider;
  //Identify the files to be compressed
  var ZIPFiles = 'd:\\projects\\hs4\\scripts\\test.htm';
  ZIPFiles = ZIPFiles + '\n' + 'd:\\projects\\hs4\\scripts\\test.zip'; 
  ZIPFiles = ZIPFiles + '\n' + 'd:\\projects\\hs4\\scripts\\*.js';

  //Add method options    
  var bRecurse = true;   
  var bIncludeDirInfo = true;
  var bIncludeHidden = true;
  var bIncludeVolume = false;
  //Create the ZIP file and execute Add method 
  ZIPPro.ZipFile = 'd:\\newzips\\newarchive.zip';
  var nStatusCode = ZIPPro.Add( ZIPFiles , bRecurse, bIncludeDirInfo, 
    bIncludeHidden, bIncludeVolume );  

  //Interpret and display the return code   
  var sMessage = ''; 
  if (nStatusCode == 0){sMessage = "Operation Succesful";}
    else if (nStatusCode == 10){sMessage = "General Warning";}
    else if (nStatusCode == 0  ){sMessage = "Success";}
    else if (nStatusCode == 10  ){sMessage = "WarningGeneral";}
    else if (nStatusCode == 30  ){sMessage = "WarningNoZipFile";}
    else if (nStatusCode == 40  ){sMessage = "WarningFilesSkipped";}
    else if (nStatusCode == 50  ){sMessage = "WarningEmptyZipFile";}
    else if (nStatusCode == 100  ){sMessage = "ErrorNoZipFile";}
    else if (nStatusCode == 110  ){sMessage = "ErrorZipStruct";}
    else if (nStatusCode == 120  ){sMessage = "ErrorMemory";}
    else if (nStatusCode == 130  ){sMessage = "ErrorBadCall";} 
    else if (nStatusCode == 140  ){sMessage = "ErrorNothingToDo";} 
    else if (nStatusCode == 150  ){sMessage = "ErrorDiskFull";} 
    else if (nStatusCode == 160  ){sMessage = "ErrorEOF";}   
    else if (nStatusCode == 180  ){sMessage = "ErrorLibInUse";} 
    else if (nStatusCode == 190  ){sMessage = "ErrorUserAbort";}
    else if (nStatusCode == 200  ){sMessage = "ErrorTestFailed";}
    else if (nStatusCode == 210  ){sMessage = "ErrorZeroTested";} 
    else if (nStatusCode == 240  ){sMessage = "ErrorDLLNotFound";}
    else if (nStatusCode == 250  ){sMessage = "ErrorInternalLogic";}
    else if (nStatusCode == 280  ){sMessage = "ErrorTempFile";}
    else if (nStatusCode == 290  ){sMessage = "ErrorRead";}
    else if (nStatusCode == 300  ){sMessage = "ErrorWrite";}
    else if (nStatusCode == 310  ){sMessage = "ErrorCantCreateFile";} 
    else if (nStatusCode == 350  ){sMessage = "ErrorParentDir";} 
    else if (nStatusCode == 370  ){sMessage = "ErrorNameRepeat";}
    else if (nStatusCode == 380  ){sMessage = "ErrorLatest";} 
    else if (nStatusCode == 400  ){sMessage = "ErrorDOSError";} 
    else if (nStatusCode == 410  ){sMessage = "ErrorMultidisk";}
    else if (nStatusCode == 420  ){sMessage = "ErrorWrongDisk";}   
    else if (nStatusCode == 430  ){sMessage = "ErrorMultidiskBadCall";}
    else if (nStatusCode == 440  ){sMessage = "ErrorCantOpenBinary";}
    else if (nStatusCode == 450  ){sMessage =
      "ErrorCantOpenSfxConfig";}
    else if (nStatusCode == 460  ){sMessage =
      "ErrorInvalidEventParam";}
    else if (nStatusCode == 470  ){sMessage = "ErrorCantWriteSfx";}
    else if (nStatusCode == 490  ){sMessage = "ErrorBinaryVersion";}
    else if (nStatusCode == 500  ){sMessage = "ErrorNotLicensed";} 
    else if (nStatusCode == 510  ){sMessage = "ErrorCantCreateDir";}
  
  app.MessageBox( sMessage ,"ZIPProvider", hsOKInfo);
}   

Delete

Syntax

Delete(Files: OleVariant): Integer; 

Description

Deletes files from an archive. Use the Files parameter to narrow down the group of files to delete. You can specify a single file, a set of files delimited by line breaks or an entire directory using wildcards. If left an empty string, all files are extracted. The function returns a status code that you can investigate to determine whether the operation succeeded.

Extract

Syntax

Extract(Files: OleVariant): Integer; 

Description

Extracts files from an archive. Use the Files parameter to narrow down the group of files to extract. You can specify a single file, a set of files delimited by line breaks or an entire directory using wildcards. If left an empty string, all files are extracted. The function returns a status code that you can investigate to determine whether the operation succeeded.

FileDate

Syntax

FileDate(nIndex: Integer): WideString; 

Description

Returns the datetime of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1.

FileIsDirectory

Syntax

FileIsDirectory(nIndex: Integer): WordBool; 

Description

Boolean. Use this function to determine whether a specific element in an archive is a directory. The index value can be from 0 to FileCount-1.

FileIsReadOnly

Syntax

FileIsReadOnly(nIndex: Integer): WordBool; 

Description

Boolean. Use this function to determine whether a specific element in an archive is read-only. The index value can be from 0 to FileCount-1.

FileIsHidden

Syntax

FileIsHidden(nIndex: Integer): WordBool; 

Description

Boolean. Use this function to determine whether a specific element in an archive is a hidden file. The index value can be from 0 to FileCount-1.

FileIsSystem

Syntax

FileIsSystem(nIndex: Integer): WordBool;  

Description

Boolean. Use this function to determine whether a specific element in an archive is a system file. The index value can be from 0 to FileCount-1.

FileIsVolume

Syntax

FileIsVolume(nIndex: Integer): WordBool; 

Description

Boolean. Use this function to determine whether a specific element in an archive is a volume label. The index value can be from 0 to FileCount-1.

FileName

Syntax

FileName(nIndex: Integer): WideString;  

Description

Returns the name of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1.

Example

Sample FileName script

//**********************************************//
// This code illustrates a loop over the content 
// of the archive, looking for a specific file name.
//***********************************************//
function Main () {
var hsOKInfo = 64;  
var app = Application;
var ZIPPro = app.ZIPProvider;
ZIPPro.ZipFile = 'd:\\zipfiles\\test.zip';         
// Loop through the contents of the ZIP file 
for ( x = 0; x < ZIPPro.FileCount; x++ ) {        
  if ( ZIPPro.FileName(x) == 'cfabort.vtm' ) {    
    app.MessageBox( "File found in the
      archive.","ZIPProvider", hsOKInfo);
    }
  }
}

FileSize

Syntax

FileSize(nIndex: Integer): Double; 

Description

Returns the size of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1.

Comments