From aadc5c595708f80719c5e07ca0f8b01b6ac300ce Mon Sep 17 00:00:00 2001 From: Vlad Dumitrescu Date: Fri, 1 Feb 2013 10:11:26 +0100 Subject: 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. --- .../java_src/com/ericsson/otp/erlang/AbstractNode.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/jinterface/java_src') 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; + } + } } -- cgit v1.2.3