Using JavaScript in HomeSite 4.0, Part III: The ZIPProvider Object's Methods, Part II | WebReference

Using JavaScript in HomeSite 4.0, Part III: The ZIPProvider Object's Methods, Part II


Using JavaScript in HomeSite 4.0, Part III

The ZIPProvider Object's Methods, Part II

Add(files, recursiveFlag, includeDirsFlag, includeHiddenFilesFlag, includeVolumeLabelsFlag)Integer

Adds files to an archive. You can specify a single file, a set of files delimited by line breaks or an entire directory using wildcards. Use the recursiveFlag parameter to add subfolders. Use includeDirsFlag to specify whether directory information should be stored in the archive. Use includeHiddenFilesFlag and includeVolumeLabelsFlag to restrict the inclusion of hidden files or volume labels. Do not set the includeVolumeLabelsFlag parameter to true unless you specify the drive letter as the first element in the files parameter (files parameter may contain multiple elements separated by line breaks). The function returns a status code which can be investigated to determine whether the operation succeeded. Click here to see the table of status codes. The following script adds three files to an archive and prints the return code:

function Main()  
  var app = Application;
    
  // Identify the files to be compressed
  var ZIPFiles = "u:\\yehuda\\Column50\\test.js";
  ZIPFiles = ZIPFiles + "\n" + "u:\\yehuda\\Column50\\test2.js";
  ZIPFiles = ZIPFiles + "\n" + "u:\\yehuda\\Column50\\test3.js";
    
  //  Create the ZIP file and execute Add method
  app.ZIPProvider.ZipFile = "u:\\yehuda\\Column50\\test.zip";
  var returnCode = app.ZIPProvider.Add(ZIPFiles , true, true, true, false );
  
  //  Interpret and display the return code 
  var message = "";
  if (returnCode == 0) message = "Operation Successful"
  else if (returnCode == 10) message = "WarningGeneral"
  else if (returnCode == 30) message = "WarningNoZipFile"
  else if (returnCode == 40) message = "WarningFilesSkipped"
  else if (returnCode == 50) message = "WarningEmptyZipFile" 
  else if (returnCode == 100) message = "ErrorNoZipFile" 
  else if (returnCode == 110) message = "ErrorZipStruct" 
  else if (returnCode == 120) message = "ErrorMemory" 
  else if (returnCode == 130) message = "ErrorBadCall" 
  else if (returnCode == 140) message = "ErrorNothingToDo" 
  else if (returnCode == 150) message = "ErrorDiskFull" 
  else if (returnCode == 160) message = "ErrorEOF" 
  else if (returnCode == 180) message = "ErrorLibInUse" 
  else if (returnCode == 190) message = "ErrorUserAbort" 
  else if (returnCode == 200) message = "ErrorTestFailed" 
  else if (returnCode == 210) message = "ErrorZeroTested" 
  else if (returnCode == 240) message = "ErrorDLLNotFound" 
  else if (returnCode == 250) message = "ErrorInternalLogic" 
  else if (returnCode == 280) message = "ErrorTempFile" 
  else if (returnCode == 290) message = "ErrorRead" 
  else if (returnCode == 300) message = "ErrorWrite" 
  else if (returnCode == 310) message = "ErrorCantCreateFile" 
  else if (returnCode == 350) message = "ErrorParentDir" 
  else if (returnCode == 370) message = "ErrorNameRepeat" 
  else if (returnCode == 380) message = "ErrorLatest" 
  else if (returnCode == 400) message = "ErrorDOSError" 
  else if (returnCode == 410) message = "ErrorMultidisk" 
  else if (returnCode == 420) message = "ErrorWrongDisk" 
  else if (returnCode == 430) message = "ErrorMultidiskBadCall" 
  else if (returnCode == 440) message = "ErrorCantOpenBinary" 
  else if (returnCode == 450) message = "ErrorCantOpenSfxConfig" 
  else if (returnCode == 460) message = "ErrorInvalidEventParam" 
  else if (returnCode == 470) message = "ErrorCantWriteSfx" 
  else if (returnCode == 490) message = "ErrorBinaryVersion" 
  else if (returnCode == 500) message = "ErrorNotLicensed" 
  else if (returnCode == 510) message = "ErrorCantCreateDir"; 
  app.MessageBox(message ,"ZIPProvider", 0);
}   

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: October 11, 1999
Revised: October 15, 1999

URL: http://www.webreference.com/js/column50/zipmeth2.html