aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-03-21 16:51:18 +0100
committerBjörn-Egil Dahlberg <[email protected]>2016-03-21 16:51:18 +0100
commitf178adaeec2a6c103509763c3a19dca41aaac2c6 (patch)
tree51f9d7c1604b4f9ca5d48bd725f080368e3f2b27 /lib
parente64308c12f412673ea08ad1254690272e929b593 (diff)
parent77ae8d93402b40aa781387831adf6271caa491a4 (diff)
downloadotp-f178adaeec2a6c103509763c3a19dca41aaac2c6.tar.gz
otp-f178adaeec2a6c103509763c3a19dca41aaac2c6.tar.bz2
otp-f178adaeec2a6c103509763c3a19dca41aaac2c6.zip
Merge branch 'egil/fix-filename_basedir-windows'
* egil/fix-filename_basedir-windows: stdlib: Fix filename:basedir/2,3
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/filename.erl39
1 files changed, 29 insertions, 10 deletions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index d921a69108..37f87b1ff9 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -1068,24 +1068,43 @@ basedir_darwin(Type) ->
%% user_cache %LOCALAPPDATA%[/$author]/$appname[/$version]/Cache
%% user_log %LOCALAPPDATA%[/$author]/$appname[/$version]/Logs
+-define(basedir_windows_user_data, "Local").
+-define(basedir_windows_user_config, "Roaming").
+-define(basedir_windows_user_cache, "Local"). %% Cache is added later
+-define(basedir_windows_user_log, "Local"). %% Logs is added later
+
basedir_windows(Type) ->
%% If LOCALAPPDATA is not defined we are likely on an
%% XP machine. Use APPDATA instead.
- AppData = basedir_windows_appdata(),
- case Type of
- user_data -> getenv("LOCALAPPDATA", AppData);
- user_config -> AppData;
- user_cache -> getenv("LOCALAPPDATA", AppData);
- user_log -> getenv("LOCALAPPDATA", AppData);
- site_data -> [];
- site_config -> []
+ case basedir_windows_appdata() of
+ noappdata ->
+ %% No AppData is set
+ %% Probably running MSYS
+ case Type of
+ user_data -> basedir_join_home(?basedir_windows_user_data);
+ user_config -> basedir_join_home(?basedir_windows_user_config);
+ user_cache -> basedir_join_home(?basedir_windows_user_cache);
+ user_log -> basedir_join_home(?basedir_windows_user_log);
+ site_data -> [];
+ site_config -> []
+ end;
+ {ok, AppData} ->
+ case Type of
+ user_data -> getenv("LOCALAPPDATA", AppData);
+ user_config -> AppData;
+ user_cache -> getenv("LOCALAPPDATA", AppData);
+ user_log -> getenv("LOCALAPPDATA", AppData);
+ site_data -> [];
+ site_config -> []
+ end
end.
basedir_windows_appdata() ->
case os:getenv("APPDATA") of
Invalid when Invalid =:= false orelse Invalid =:= [] ->
- erlang:error(noappdata);
- Val -> Val
+ noappdata;
+ Val ->
+ {ok, Val}
end.
%% basedir aux