The ZIPProvider object is the general purpose PKZIP services object used by HomeSite and ColdFusion Studio for ZIP file composition and extraction. You can use this object in your VTOM scripts for low-level PKZIP operations from within HomeSite and ColdFusion Studio. Since Allaire uses a licensed control for its ZIP operations, you cannot use ZIPProvider outside of HomeSite or ColdFusion Studio.
Sets/returns the compression level use to compress the archive file. This can be set to a value from 0 to 9, with 0 representing no compression, 1 the fastest compression and 9 the slowest, but most size efficient compression.
Sets/returns the directory path where the files will be extracted from an existing archive file using the Extract method.
Returns the number of elements in the archive.
Sets/returns whether the newly extracted files overwrite any existing file in the ExtractionDir directory.
Sets/returns the password for the archive file. Set this property when extracting password protected files or if you want to password protect files in an archive file you just created.
Sets/returns the comment for the archive file. You can use this property to read a comment of an existing archive file, or set the comment for a new archive file you created.
Sets/returns 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, Extract methods on the file.
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); }
function Add(Files: OleVariant; bRecurse, bIncludeDirs, bIncludeHiddenFiles, bIncludeVolumeLabels: WordBool): Integer;
Adds files to an archive. The Files parameter can be used 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 which can be investigated to determine the operations succeess.
See example below:
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); }
function Delete(Files: OleVariant): Integer;
Deletes files from an archive. The Files parameter can be used 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 will be extracted. The function returns a status code which can be investigated to determine whether the operation succeeded. See example above.
function Extract(Files: OleVariant): Integer;
Extracts files from an archive. The Files parameter can be used 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 will be extracted. The function returns a status code which can be investigated to determine whether the operation succeeded. See example above.
function FileDate(nIndex: Integer): WideString;
Returns the datetime of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1.
function FileIsDirectory(nIndex: Integer): WordBool;
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.
function FileIsReadOnly(nIndex: Integer): WordBool;
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.
function FileIsHidden(nIndex: Integer): WordBool;
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.
function FileIsSystem(nIndex: Integer): WordBool;
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.
function FileName(nIndex: Integer): WideString;
Returns the name of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1. The following 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); } }
function FileSize(nIndex: Integer): Double;
Returns the size of an existing archive file element (file/directory/volume) by index. The index value can be from 0 to FileCount-1.
function FileIsVolume(nIndex: Integer): WordBool;
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.