home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 December
/
Chip_2001-12_cd1.bin
/
servis
/
mozilla_cz
/
regcz.xpi
/
install.js
Wrap
Text File
|
2001-09-15
|
4KB
|
150 lines
// this function verifies disk space in kilobytes
function verifyDiskSpace(dirPath, spaceRequired)
{
var spaceAvailable;
// Get the available disk space on the given path
spaceAvailable = fileGetDiskSpaceAvailable(dirPath);
// Convert the available disk space into kilobytes
spaceAvailable = parseInt(spaceAvailable / 1024);
// do the verification
if(spaceAvailable < spaceRequired)
{
logComment("Insufficient disk space: " + dirPath);
logComment(" required : " + spaceRequired + " kB");
logComment(" available: " + spaceAvailable + " kB");
return(false);
}
return(true);
}
// this function deletes a file if it exists
function deleteThisFile(dirKey, file)
{
var fFileToDelete;
fFileToDelete = getFolder(dirKey, file);
logComment(file + " file: " + fFileToDelete);
if(File.exists(fFileToDelete))
{
fileDelete(fFileToDelete);
return(true);
}
else
return(false);
}
// this function deletes a folder (recursively) if it exists
function deleteThisFolder(dirKey, folder)
{
var fToDelete;
fToDelete = getFolder(dirKey, folder);
logComment(folder + " folder: " + fToDelete);
if(File.exists(fToDelete))
{
File.dirRemove(fToDelete, true);
return(true);
}
else
return(false);
}
// OS type detection
// which platform?
function getPlatform()
{
var platformStr;
var platformNode;
if('platform' in Install)
{
platformStr = new String(Install.platform);
if (!platformStr.search(/^Macintosh/))
platformNode = 'mac';
else if (!platformStr.search(/^Win/))
platformNode = 'win';
else
platformNode = 'unix';
}
else
{
var fOSMac = getFolder("Mac System");
var fOSWin = getFolder("Win System");
logComment("fOSMac: " + fOSMac);
logComment("fOSWin: " + fOSWin);
if(fOSMac != null)
platformNode = 'mac';
else if(fOSWin != null)
platformNode = 'win';
else
platformNode = 'unix';
}
return platformNode;
}
var srDest = 50;
var err;
var fProgram;
var platformNode;
platformNode = getPlatform();
logComment("initInstall: platformNode=" + platformNode);
// end
// end - OS type detection
// main
// --- LOCALIZATION NOTE: translate only these ---
var prettyName = "Czech(CZ) Region Pack";
var chromeNode = "CZ";
// --- END LOCALIZABLE RESOURCES ---
var regName = "locales/mozilla/" + chromeNode;
var chromeName = chromeNode + ".jar";
var localeName = "locale/" + chromeNode + "/";
err = initInstall(prettyName, regName, "0.9.4");
logComment("initInstall: " + err);
fProgram = getFolder("Program");
logComment("fProgram: " + fProgram);
if (verifyDiskSpace(fProgram, srDest))
{
err = addDirectory("",
"0.9.4",
"bin", // dir name in jar to extract
fProgram, // Where to put this file (Returned from GetFolder)
"", // subdir name to create relative to fProgram
true); // Force Flag
logComment("addDirectory() returned: " + err);
// register chrome
var cf = getFolder("Chrome");
registerChrome(LOCALE | DELAYED_CHROME, getFolder(cf, chromeName), localeName + "communicator-region/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder(cf, chromeName), localeName + "editor-region/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder(cf, chromeName), localeName + "global-region/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder(cf, chromeName), localeName + "messenger-region/");
registerChrome(LOCALE | DELAYED_CHROME, getFolder(cf, chromeName), localeName + "navigator-region/");
// check return value
if (err == SUCCESS)
{
err = performInstall();
logComment("performInstall() returned: " + err);
alert("Install completed successfully");
}
else
{
cancelInstall(err);
logComment("cancelInstall by error: " + err);
}
}
else
cancelInstall(INSUFFICIENT_DISK_SPACE);
// end main