aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-10-13 14:23:50 +0200
committerLukas Larsson <[email protected]>2017-10-13 14:23:50 +0200
commitb7a5e370d7a7a1b6cfc9c96cb56d7acfc0fa944b (patch)
treed6ef43983d9f110e91c3011c736c3a2d58dd5e35 /erts/etc
parent45787fb84c07352171cac7114ef28057c8305a8d (diff)
downloadotp-b7a5e370d7a7a1b6cfc9c96cb56d7acfc0fa944b.tar.gz
otp-b7a5e370d7a7a1b6cfc9c96cb56d7acfc0fa944b.tar.bz2
otp-b7a5e370d7a7a1b6cfc9c96cb56d7acfc0fa944b.zip
erts: Use PROFILE dir as home on windows
Instead of using C:\Windows we use the profile path as the home path on windows. The profile path normally resolves to C:\Users\%USERNAME%. This fixes an issue where the default path to the .erlang.cookie was not the same for jinterface as for erl.
Diffstat (limited to 'erts/etc')
-rw-r--r--erts/etc/common/erlexec.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c
index 51ed2d0dff..eaa94cd5e4 100644
--- a/erts/etc/common/erlexec.c
+++ b/erts/etc/common/erlexec.c
@@ -36,6 +36,7 @@
#ifdef __WIN32__
# include "erl_version.h"
# include "init_file.h"
+# include <Shlobj.h>
#endif
#define NO 0
@@ -1541,17 +1542,16 @@ static void get_parameters(int argc, char** argv)
static void
get_home(void)
{
- int len;
- char tmpstr[MAX_PATH+1];
+ wchar_t *profile;
char* homedrive;
char* homepath;
homedrive = get_env("HOMEDRIVE");
homepath = get_env("HOMEPATH");
if (!homedrive || !homepath) {
- if (len = GetWindowsDirectory(tmpstr,MAX_PATH)) {
- home = emalloc(len+1);
- strcpy(home,tmpstr);
+ if (SHGetKnownFolderPath(&FOLDERID_Profile, 0, NULL, &profile) == S_OK) {
+ home = utf16_to_utf8(profile);
+ /* CoTaskMemFree(profile); */
} else
error("HOMEDRIVE or HOMEPATH is not set and GetWindowsDir failed");
} else {