home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 2001 - Modelworks Software
-
- /**
- @Tool: installer~installs the specified files included in
- a manifest.txt file located in a zip file. The format of
- the manifest file is:
- <item name in the zip file>:<relative application folder path>
- The <relative application folder path> should not begin with a
- '\' nor end with a '\'. Backslashes should not be escaped in the
- manifest file. The item name must match a name in the archive.
- If you include folder information then the relative path must
- be part of the item name and the target path should not include
- the relative path. For an example see the Sample folder in the
- Installer folder.
- @EndTool:
- @Summary: installer~installs the specified files in a zip file
- */
-
- var gOutput = getOutput();
-
- function DoCommand()
- {
- var file = chooseFile("Choose Installer", "ZIP file", "*.zip");
- if (file)
- {
- var zip = File.newZip(file.path);
- if (zip)
- {
- var applicationPath = File.getApplicationPath();
- var installerDirectory = newFile(applicationPath + "\\Ide\\Data\\Installer");
- if (installerDirectory.create())
- {
- RunInstaller(zip, installerDirectory);
- }
- }
- }
- }
-
- function RunInstaller(zipfile, tempdir)
- {
- if (zipfile)
- {
- if (!tempdir.exists())
- {
- tempdir.create();
- }
-
- if (tempdir.exists())
- {
- var applicationPath = File.getApplicationPath();
- var manifestPath = tempdir.path + "\\manifest.txt"
- zipfile.extract("manifest.txt", manifestPath); // extract the manifest
-
- var manifest = openEditor(manifestPath);
- if (manifest)
- {
- var lineCount = manifest.getLineCount();
- for (var index = 0; index < lineCount; index++)
- {
- var lineData = manifest.copy(index);
- var elements = lineData.split(':');
- var item = elements[0];
- var target = newFile(applicationPath + "\\" + elements[1] + "\\" + item);
- zipfile.extract(item, target.path); // install the file
- gOutput.writeLine("Installed file: " + target.path);
- }
- manifest.close(false,false);
- }
- else
- {
- gOutput.writeLine("Error: this is not a valid installer. No manifest.txt file found in " + file.path);
- }
- }
- }
- }
-
- !!/Script
-
-