|
Lines 216-221
Link Here
|
| 216 |
protected File logFile = null; |
216 |
protected File logFile = null; |
| 217 |
protected BufferedWriter log = null; |
217 |
protected BufferedWriter log = null; |
| 218 |
protected boolean newSession = true; |
218 |
protected boolean newSession = true; |
|
|
219 |
private String launcher = null; |
| 219 |
|
220 |
|
| 220 |
/** |
221 |
/** |
| 221 |
* A structured form for a version identifier. |
222 |
* A structured form for a version identifier. |
|
Lines 1397-1403
Link Here
|
| 1397 |
// look for the launcher location |
1398 |
// look for the launcher location |
| 1398 |
if (args[i - 1].equalsIgnoreCase(LAUNCHER)) { |
1399 |
if (args[i - 1].equalsIgnoreCase(LAUNCHER)) { |
| 1399 |
//not doing anything with this right now, but still consume it |
1400 |
//not doing anything with this right now, but still consume it |
| 1400 |
//launcher = arg; |
1401 |
launcher = arg; |
| 1401 |
found = true; |
1402 |
found = true; |
| 1402 |
} |
1403 |
} |
| 1403 |
|
1404 |
|
|
Lines 1619-1624
Link Here
|
| 1619 |
return installLocation; |
1620 |
return installLocation; |
| 1620 |
} |
1621 |
} |
| 1621 |
|
1622 |
|
|
|
1623 |
File installFile = getLauncherLocation(); |
| 1624 |
if (installFile == null) |
| 1625 |
installFile = getCodeSourceLocation(); |
| 1626 |
// normalize to not have leading / so we can check the form |
| 1627 |
String path = installFile.toString().replace('\\', '/'); |
| 1628 |
// TODO need a better test for windows |
| 1629 |
// If on Windows then canonicalize the drive letter to be lowercase. |
| 1630 |
// remember that there may be UNC paths |
| 1631 |
if (File.separatorChar == '\\') |
| 1632 |
if (Character.isUpperCase(path.charAt(0))) { |
| 1633 |
char[] chars = path.toCharArray(); |
| 1634 |
chars[0] = Character.toLowerCase(chars[0]); |
| 1635 |
path = new String(chars); |
| 1636 |
} |
| 1637 |
installFile = new File(path); |
| 1638 |
try { |
| 1639 |
// create a file URL (via File) to normalize the form (e.g., put |
| 1640 |
// the leading / on if necessary) |
| 1641 |
URL installURL = installFile.toURL(); |
| 1642 |
path = installURL.getFile(); |
| 1643 |
installLocation = new URL(installURL.getProtocol(), installURL.getHost(), installURL.getPort(), path); |
| 1644 |
System.getProperties().put(PROP_INSTALL_AREA, installLocation.toExternalForm()); |
| 1645 |
} catch (MalformedURLException e) { |
| 1646 |
// TODO Very unlikely case. log here. |
| 1647 |
} |
| 1648 |
if (debug) |
| 1649 |
System.out.println("Install location:\n " + installLocation); //$NON-NLS-1$ |
| 1650 |
return installLocation; |
| 1651 |
} |
| 1652 |
|
| 1653 |
private File getCodeSourceLocation() { |
| 1622 |
ProtectionDomain domain = Main.class.getProtectionDomain(); |
1654 |
ProtectionDomain domain = Main.class.getProtectionDomain(); |
| 1623 |
CodeSource source = null; |
1655 |
CodeSource source = null; |
| 1624 |
URL result = null; |
1656 |
URL result = null; |
|
Lines 1637-1674
Link Here
|
| 1637 |
result = source.getLocation(); |
1669 |
result = source.getLocation(); |
| 1638 |
|
1670 |
|
| 1639 |
String path = decode(result.getFile()); |
1671 |
String path = decode(result.getFile()); |
| 1640 |
// normalize to not have leading / so we can check the form |
|
|
| 1641 |
File file = new File(path); |
| 1642 |
path = file.toString().replace('\\', '/'); |
| 1643 |
// TODO need a better test for windows |
| 1644 |
// If on Windows then canonicalize the drive letter to be lowercase. |
| 1645 |
// remember that there may be UNC paths |
| 1646 |
if (File.separatorChar == '\\') |
| 1647 |
if (Character.isUpperCase(path.charAt(0))) { |
| 1648 |
char[] chars = path.toCharArray(); |
| 1649 |
chars[0] = Character.toLowerCase(chars[0]); |
| 1650 |
path = new String(chars); |
| 1651 |
} |
| 1652 |
if (path.toLowerCase().endsWith(".jar")) //$NON-NLS-1$ |
1672 |
if (path.toLowerCase().endsWith(".jar")) //$NON-NLS-1$ |
| 1653 |
path = path.substring(0, path.lastIndexOf("/") + 1); //$NON-NLS-1$ |
1673 |
path = path.substring(0, path.lastIndexOf("/") + 1); //$NON-NLS-1$ |
| 1654 |
if (path.toLowerCase().endsWith("/plugins/")) //$NON-NLS-1$ |
1674 |
if (path.toLowerCase().endsWith("/plugins/")) //$NON-NLS-1$ |
| 1655 |
path = path.substring(0, path.length() - "/plugins/".length()); //$NON-NLS-1$ |
1675 |
path = path.substring(0, path.length() - "/plugins/".length()); //$NON-NLS-1$ |
| 1656 |
try { |
1676 |
return new File(path); |
| 1657 |
try { |
1677 |
} |
| 1658 |
// create a file URL (via File) to normalize the form (e.g., put |
1678 |
|
| 1659 |
// the leading / on if necessary) |
1679 |
private File getLauncherLocation() { |
| 1660 |
path = new File(path).toURL().getFile(); |
1680 |
if (launcher == null) |
| 1661 |
} catch (MalformedURLException e1) { |
1681 |
return null; |
| 1662 |
// will never happen. The path is straight from a URL. |
1682 |
File exe = new File(launcher); |
| 1663 |
} |
1683 |
if (exe.getParent() == null) |
| 1664 |
installLocation = new URL(result.getProtocol(), result.getHost(), result.getPort(), path); |
1684 |
return null; |
| 1665 |
System.getProperties().put(PROP_INSTALL_AREA, installLocation.toExternalForm()); |
1685 |
File launcherDir = new File(exe.getParent()); |
| 1666 |
} catch (MalformedURLException e) { |
1686 |
return (launcherDir.exists() && launcherDir.isDirectory()) ? launcherDir : null; |
| 1667 |
// TODO Very unlikely case. log here. |
1687 |
|
| 1668 |
} |
|
|
| 1669 |
if (debug) |
| 1670 |
System.out.println("Install location:\n " + installLocation); //$NON-NLS-1$ |
| 1671 |
return installLocation; |
| 1672 |
} |
1688 |
} |
| 1673 |
|
1689 |
|
| 1674 |
/* |
1690 |
/* |