Browse Source

Rewrite code around remove_links/1 to make it clearer

pull/489/head
Viacheslav V. Kovalev 9 years ago
parent
commit
9a83c35a6f
1 changed files with 5 additions and 7 deletions
  1. +5
    -7
      src/rebar_prv_common_test.erl

+ 5
- 7
src/rebar_prv_common_test.erl View File

@ -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].

Loading…
Cancel
Save