home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / mwjpp516.exe / %MAINDIR% / Tools / Installer / install.script < prev   
Encoding:
Text File  |  2001-06-19  |  2.2 KB  |  80 lines

  1. !!Script
  2. // Copyright ⌐ 2001 - Modelworks Software
  3.  
  4. /**
  5. @Tool: installer~installs the specified files included in
  6. a manifest.txt file located in a zip file. The format of
  7. the manifest file is:
  8. <item name in the zip file>:<relative application folder path>
  9. The <relative application folder path> should not begin with a
  10. '\' nor end with a '\'. Backslashes should not be escaped in the
  11. manifest file. The item name must match a name in the archive. 
  12. If you include folder information then the relative path must 
  13. be part of the item name and the target path should not include
  14. the relative path. For an example see the Sample folder in the 
  15. Installer folder.
  16. @EndTool: 
  17. @Summary: installer~installs the specified files in a zip file 
  18. */
  19.  
  20. var gOutput = getOutput();
  21.  
  22. function DoCommand()
  23. {
  24.     var file = chooseFile("Choose Installer", "ZIP file", "*.zip");
  25.     if (file)
  26.     {
  27.         var zip = File.newZip(file.path);
  28.         if (zip)
  29.         {
  30.             var applicationPath = File.getApplicationPath();
  31.             var installerDirectory = newFile(applicationPath + "\\Ide\\Data\\Installer");
  32.             if (installerDirectory.create())
  33.             {
  34.                 RunInstaller(zip, installerDirectory);
  35.             }
  36.         }
  37.     }
  38. }
  39.  
  40. function RunInstaller(zipfile, tempdir)
  41. {
  42.     if (zipfile)
  43.     {
  44.         if (!tempdir.exists())
  45.         {
  46.             tempdir.create();
  47.         }
  48.         
  49.         if (tempdir.exists())
  50.         {
  51.             var applicationPath = File.getApplicationPath();
  52.             var manifestPath = tempdir.path + "\\manifest.txt"
  53.             zipfile.extract("manifest.txt", manifestPath); // extract the manifest
  54.         
  55.             var manifest = openEditor(manifestPath);
  56.             if (manifest)
  57.             {
  58.                 var lineCount = manifest.getLineCount();
  59.                 for (var index = 0; index < lineCount; index++)
  60.                 { 
  61.                     var lineData = manifest.copy(index);
  62.                     var elements = lineData.split(':');
  63.                     var item = elements[0];
  64.                     var target = newFile(applicationPath + "\\" + elements[1] + "\\" + item);
  65.                     zipfile.extract(item, target.path); // install the file
  66.                     gOutput.writeLine("Installed file: " + target.path);
  67.                 }
  68.                 manifest.close(false,false);
  69.             }
  70.             else
  71.             {
  72.                 gOutput.writeLine("Error: this is not a valid installer. No manifest.txt file found in " + file.path);
  73.             }
  74.         }
  75.     }    
  76. }
  77.  
  78. !!/Script
  79.  
  80.