summaryrefslogtreecommitdiff
path: root/src/rebar_prv_common_test.erl
diff options
context:
space:
mode:
authorViacheslav V. Kovalev <kovyl2404@gmail.com>2015-06-27 00:23:45 +0300
committerViacheslav V. Kovalev <kovyl2404@gmail.com>2015-06-27 00:23:45 +0300
commit9a83c35a6fbfcebd1ca92c166efc930fc0f5d4c5 (patch)
treef54d1b82ce9fb35371ba23100231c59869425228 /src/rebar_prv_common_test.erl
parent44272e23b641a016b74edf0cb9849b0656e8f726 (diff)
Rewrite code around remove_links/1 to make it clearer
Diffstat (limited to 'src/rebar_prv_common_test.erl')
-rw-r--r--src/rebar_prv_common_test.erl12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index f76fdf5..6bf0533 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -347,17 +347,15 @@ reduce_path(Acc, [Component|Rest]) -> reduce_path([Component|Acc], Rest).
remove_links(Path) ->
- IsDir = ec_file:is_dir(Path),
+ IsDir = ec_file:is_dir(Path),
case ec_file:is_symlink(Path) of
true when IsDir ->
delete_dir_link(Path);
- true ->
- file:delete(Path);
- false ->
- ec_file:is_dir(Path) andalso
+ false when IsDir ->
lists:foreach(fun(ChildPath) ->
remove_links(ChildPath)
- end, sub_dirs(Path))
+ end, dir_entries(Path));
+ _ -> file:delete(Path)
end.
delete_dir_link(Path) ->
@@ -366,7 +364,7 @@ delete_dir_link(Path) ->
{win32, _} -> file:del_dir(Path)
end.
-sub_dirs(Path) ->
+dir_entries(Path) ->
{ok, SubDirs} = file:list_dir(Path),
[filename:join(Path, SubDir) || SubDir <- SubDirs].