OSX: Get application path from library path with Java7 launcher
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2164 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
b7c296cb7e
commit
6060231aa9
|
@ -21,6 +21,7 @@ package davmail.ui;
|
||||||
import davmail.util.IOUtil;
|
import davmail.util.IOUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -37,7 +38,7 @@ public class OSXInfoPlist {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String getInfoPlistContent() throws IOException {
|
protected static String getInfoPlistContent() throws IOException {
|
||||||
FileInputStream fileInputStream = new FileInputStream(INFO_PLIST_PATH);
|
FileInputStream fileInputStream = new FileInputStream(getInfoPlistPath());
|
||||||
return new String(IOUtil.readFully(fileInputStream));
|
return new String(IOUtil.readFully(fileInputStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ public class OSXInfoPlist {
|
||||||
boolean currentHideFromDock = isHideFromDock();
|
boolean currentHideFromDock = isHideFromDock();
|
||||||
if (currentHideFromDock != hideFromDock) {
|
if (currentHideFromDock != hideFromDock) {
|
||||||
String content = getInfoPlistContent();
|
String content = getInfoPlistContent();
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(INFO_PLIST_PATH);
|
FileOutputStream fileOutputStream = new FileOutputStream(getInfoPlistPath());
|
||||||
try {
|
try {
|
||||||
fileOutputStream.write(content.replaceFirst(
|
fileOutputStream.write(content.replaceFirst(
|
||||||
"<key>LSUIElement</key><string>" + (currentHideFromDock ? "1" : "0") + "</string>",
|
"<key>LSUIElement</key><string>" + (currentHideFromDock ? "1" : "0") + "</string>",
|
||||||
|
@ -82,4 +83,20 @@ public class OSXInfoPlist {
|
||||||
LOGGER.warn("Unable to update Info.plist", e);
|
LOGGER.warn("Unable to update Info.plist", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String getInfoPlistPath() throws IOException {
|
||||||
|
File file = new File(INFO_PLIST_PATH);
|
||||||
|
if (file.exists()) {
|
||||||
|
return INFO_PLIST_PATH;
|
||||||
|
}
|
||||||
|
// failover for Java7
|
||||||
|
String libraryPath = System.getProperty("java.library.path");
|
||||||
|
if (libraryPath != null && libraryPath.endsWith("Contents/MacOS")) {
|
||||||
|
file = new File(libraryPath.replace("Contents/MacOS", INFO_PLIST_PATH));
|
||||||
|
if (file.exists()) {
|
||||||
|
return INFO_PLIST_PATH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("Info.plist file not found");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue