GungHo really, really wants us installing to Program Files. This almost surely creates permission problems but since they require all their users to be running in a mode that gives them full access to Program Files, I guess they may be okay. So, add the win_install_to_program_files parameter we can pass to the getdown applet.
This commit is contained in:
@@ -31,6 +31,10 @@ import java.net.URL;
|
|||||||
import javax.swing.JApplet;
|
import javax.swing.JApplet;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
|
import ca.beq.util.win32.registry.RegistryKey;
|
||||||
|
import ca.beq.util.win32.registry.RegistryValue;
|
||||||
|
import ca.beq.util.win32.registry.RootKey;
|
||||||
|
|
||||||
import com.samskivert.util.RunAnywhere;
|
import com.samskivert.util.RunAnywhere;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
@@ -231,24 +235,36 @@ public class GetdownApplet extends JApplet
|
|||||||
|
|
||||||
// when run from an applet, we install to the user's home directory
|
// when run from an applet, we install to the user's home directory
|
||||||
String root;
|
String root;
|
||||||
|
boolean includeHome = true;
|
||||||
if (RunAnywhere.isWindows()) {
|
if (RunAnywhere.isWindows()) {
|
||||||
root = "Application Data";
|
String propStr = System.getProperty("win_install_to_program_files");
|
||||||
String verStr = System.getProperty("os.version");
|
boolean useProgFiles =
|
||||||
try {
|
StringUtil.isBlank(propStr) ? false : propStr.equals("true");
|
||||||
if (Float.parseFloat(verStr) >= 6.0f) {
|
if (useProgFiles) {
|
||||||
// Vista makes us write it here.... Yay.
|
RegistryKey.initialize();
|
||||||
root = "AppData" + File.separator + "LocalLow";
|
RegistryKey r = new RegistryKey(RootKey.HKEY_LOCAL_MACHINE, PROGRAM_FILES);
|
||||||
|
root = r.getValue("ProgramFilesDir").getStringValue();
|
||||||
|
includeHome = false;
|
||||||
|
} else {
|
||||||
|
root = "Application Data";
|
||||||
|
String verStr = System.getProperty("os.version");
|
||||||
|
try {
|
||||||
|
if (Float.parseFloat(verStr) >= 6.0f) {
|
||||||
|
// Vista makes us write it here.... Yay.
|
||||||
|
root = "AppData" + File.separator + "LocalLow";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.warning("Couldn't parse OS version [vers=" + verStr +
|
||||||
|
", error=" + e + "].");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
Log.warning("Couldn't parse OS version [vers=" + verStr + ", error=" + e + "].");
|
|
||||||
}
|
}
|
||||||
} else if (RunAnywhere.isMacOS()) {
|
} else if (RunAnywhere.isMacOS()) {
|
||||||
root = "Library" + File.separator + "Application Support";
|
root = "Library" + File.separator + "Application Support";
|
||||||
} else /* isLinux() or something wacky */ {
|
} else /* isLinux() or something wacky */ {
|
||||||
root = ".getdown";
|
root = ".getdown";
|
||||||
}
|
}
|
||||||
File appdir = new File(System.getProperty("user.home") + File.separator + root +
|
String homePrefix = includeHome ? System.getProperty("user.home") + File.separator : "";
|
||||||
File.separator + appname);
|
File appdir = new File(homePrefix + root + File.separator + appname);
|
||||||
|
|
||||||
// if our application directory does not exist, auto-create it
|
// if our application directory does not exist, auto-create it
|
||||||
if (!appdir.exists() || !appdir.isDirectory()) {
|
if (!appdir.exists() || !appdir.isDirectory()) {
|
||||||
@@ -302,4 +318,6 @@ public class GetdownApplet extends JApplet
|
|||||||
|
|
||||||
/** An error encountered during initialization. */
|
/** An error encountered during initialization. */
|
||||||
protected String _errmsg;
|
protected String _errmsg;
|
||||||
|
|
||||||
|
protected static final String PROGRAM_FILES = "Software\\Microsoft\\Windows\\CurrentVersion";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user