summaryrefslogtreecommitdiffstats
path: root/src/core/ephraim_util.erl
blob: cdf9cea419c345a53c81e3ab072702179c4a7368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-module(ephraim_util).
-compile([debug_info, export_all]).

-spec send_all([term()], term()) -> term().
send_all(Dest, Message) ->
    lists:foldr(fun erlang:send/2, Message, Dest).

-spec send_all_values(dict(), term()) -> term().
send_all_values(Dest, Message) ->
    dict:fold(fun(_,Value,Msg) -> Value ! Msg end, Message, Dest).

-spec config_path() -> string().
config_path() ->
    Path = case os:getenv("XDG_CONFIG_HOME") of
	       false ->
		   os:getenv("HOME") ++ "/.config";
	       ConfigHome ->
		   ConfigHome
	   end ++ "/ephraim",
    case file:read_file_info(Path) of
	{ok, _} ->
	    ok;
	{error, _} ->
	    file:make_dir(Path)
    end,
    Path.