aboutsummaryrefslogtreecommitdiffstats
path: root/lib/jinterface
diff options
context:
space:
mode:
authorVlad Dumitrescu <[email protected]>2013-02-01 10:11:26 +0100
committerVlad Dumitrescu <[email protected]>2013-02-01 11:34:02 +0100
commitaadc5c595708f80719c5e07ca0f8b01b6ac300ce (patch)
treeb25d816fa7f982beb2254919dd7adb291f946e41 /lib/jinterface
parent68b804f34d4ec420d86953e3f519179a40fbee8f (diff)
downloadotp-aadc5c595708f80719c5e07ca0f8b01b6ac300ce.tar.gz
otp-aadc5c595708f80719c5e07ca0f8b01b6ac300ce.tar.bz2
otp-aadc5c595708f80719c5e07ca0f8b01b6ac300ce.zip
jinterface: fix finding cookie file on windows
Jinterface uses System.getProperty("user.home") to locate the user's home and the cookie file. On Windows, the result might be different than the value used by Erlang, which looks first to the HOMEDRIVE and HOMEPATH variables. The fix makes jinterface use the same logic.
Diffstat (limited to 'lib/jinterface')
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java
index cea5080607..968f284bff 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java
@@ -118,8 +118,9 @@ public class AbstractNode {
localHost = "localhost";
}
- final String dotCookieFilename = System.getProperty("user.home")
- + File.separator + ".erlang.cookie";
+ final String homeDir = getHomeDir();
+ final String dotCookieFilename = homeDir + File.separator
+ + ".erlang.cookie";
BufferedReader br = null;
try {
@@ -251,4 +252,15 @@ public class AbstractNode {
public String toString() {
return node();
}
+
+ private static String getHomeDir() {
+ final String home = System.getProperty("user.home");
+ if (System.getProperty("os.name").toLowerCase().contains("windows")) {
+ final String drive = System.getenv("HOMEDRIVE");
+ final String path = System.getenv("HOMEPATH");
+ return (drive != null && path != null) ? drive + path : home;
+ } else {
+ return home;
+ }
+ }
}