diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-02-21 17:27:16 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-02-21 17:27:16 -0500 |
commit | 8988c9ff6c09da0e2e2e3b7285720e7dfe712730 (patch) | |
tree | 06c73f7b45512574b4761796b2c66125dacb2868 /src/rebar_dir.erl | |
parent | df30a93891fd85fcad566c100c53e463448662a1 (diff) | |
parent | 24383e228373d14c23c56225fe3e974dcbb0b43d (diff) |
Merge pull request #166 from tsloughter/xdg
follow xdg standard. fixes #122
Diffstat (limited to 'src/rebar_dir.erl')
-rw-r--r-- | src/rebar_dir.erl | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl index 58ce716..3962bf8 100644 --- a/src/rebar_dir.erl +++ b/src/rebar_dir.erl @@ -7,8 +7,13 @@ lib_dirs/1, home_dir/0, global_config_dir/1, + global_config/1, + global_config/0, + global_cache_dir/1, + local_cache_dir/0, get_cwd/0, - ensure_dir/1, + template_globals/1, + template_dir/1, src_dirs/1, ebin_dir/0, processing_base_dir/1, @@ -47,23 +52,31 @@ home_dir() -> global_config_dir(State) -> Home = home_dir(), - rebar_state:get(State, global_rebar_dir, filename:join(Home, ?CONFIG_DIR)). + rebar_state:get(State, global_rebar_dir, filename:join([Home, ".config", "rebar3"])). + +global_config(State) -> + filename:join(global_config_dir(State), "config"). + +global_config() -> + Home = home_dir(), + filename:join([Home, ".config", "rebar3", "config"]). + +global_cache_dir(State) -> + Home = home_dir(), + rebar_state:get(State, global_rebar_dir, filename:join([Home, ".cache", "rebar3"])). + +local_cache_dir() -> + filename:join(get_cwd(), ".rebar3"). get_cwd() -> {ok, Dir} = file:get_cwd(), Dir. -%% TODO: filelib:ensure_dir/1 corrected in R13B04. Remove when we drop -%% support for OTP releases older than R13B04. -ensure_dir(Path) -> - case filelib:ensure_dir(Path) of - ok -> - ok; - {error,eexist} -> - ok; - Error -> - Error - end. +template_globals(State) -> + filename:join([global_config_dir(State), "templates", "globals"]). + +template_dir(State) -> + filename:join([global_config_dir(State), "templates"]). -spec src_dirs([string()]) -> [file:filename(), ...]. src_dirs([]) -> |