summaryrefslogtreecommitdiff
path: root/lib/observer
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2021-10-26 16:01:44 +0200
committerLukas Larsson <lukas@erlang.org>2021-12-06 14:07:30 +0100
commit9a05c83298ce197d26488d11074c49b23d5eb3df (patch)
treef0babfbde940d8d683b76980cb7b5ef1bcf59620 /lib/observer
parent2be9adac4a0aebd1aa7e7158158de7e2463d5daa (diff)
downloaderlang-9a05c83298ce197d26488d11074c49b23d5eb3df.tar.gz
kernel: Search $XDG_CONFIG_HOME for erlang cookie
Diffstat (limited to 'lib/observer')
-rw-r--r--lib/observer/src/observer_wx.erl19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl
index 07e2fb1b29..eb7d802876 100644
--- a/lib/observer/src/observer_wx.erl
+++ b/lib/observer/src/observer_wx.erl
@@ -29,6 +29,7 @@
%% Includes
-include_lib("wx/include/wx.hrl").
+-include_lib("kernel/include/file.hrl").
-include("observer_defs.hrl").
@@ -658,14 +659,16 @@ create_connect_dialog(connect, #state{frame = Frame}) ->
wxWindow:setSizerAndFit(Dialog, VSizer),
wxSizer:setSizeHints(VSizer, Dialog),
{ok,[[HomeDir]]} = init:get_argument(home),
- CookiePath = filename:join(HomeDir, ".erlang.cookie"),
- DefaultCookie = case filelib:is_file(CookiePath) of
- true ->
- {ok, Bin} = file:read_file(CookiePath),
- binary_to_list(Bin);
- false ->
- ""
- end,
+ XDGHome = filename:basedir(user_config,"erlang"),
+ DefaultCookie =
+ case file:path_open([HomeDir,XDGHome], ".erlang.cookie", read) of
+ {ok, File, _} ->
+ {ok, #file_info{ size = Sz }} = file:read_file_info(File),
+ {ok, Data} = file:read(File, Sz),
+ Data;
+ _ ->
+ ""
+ end,
wxTextCtrl:setValue(CookieCtrl, DefaultCookie),
case wxDialog:showModal(Dialog) of
?wxID_OK ->