From 9a83c35a6fbfcebd1ca92c166efc930fc0f5d4c5 Mon Sep 17 00:00:00 2001 From: "Viacheslav V. Kovalev" Date: Sat, 27 Jun 2015 00:23:45 +0300 Subject: Rewrite code around remove_links/1 to make it clearer --- src/rebar_prv_common_test.erl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/rebar_prv_common_test.erl') 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]. -- cgit v1.1