From 9ad39c979a5cf0aa9f831f6a7523f8afe1abcf2b Mon Sep 17 00:00:00 2001 From: "Viacheslav V. Kovalev" Date: Mon, 1 Jun 2015 23:22:02 +0300 Subject: Fix windows-related issues --- src/rebar_prv_common_test.erl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 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 710922a..f76fdf5 100644 --- a/src/rebar_prv_common_test.erl +++ b/src/rebar_prv_common_test.erl @@ -345,22 +345,27 @@ reduce_path([_|Acc], [".."|Rest]) -> reduce_path(Acc, Rest); reduce_path([], [".."|Rest]) -> reduce_path([], Rest); reduce_path(Acc, [Component|Rest]) -> reduce_path([Component|Acc], Rest). -remove_links(Path) -> - case ec_file:is_dir(Path) of - false -> ok; - true -> remove_links1(Path) - end. -remove_links1(Path) -> +remove_links(Path) -> + IsDir = ec_file:is_dir(Path), case ec_file:is_symlink(Path) of - true -> + true when IsDir -> + delete_dir_link(Path); + true -> file:delete(Path); false -> - lists:foreach(fun(ChildPath) -> - remove_links(ChildPath) - end, sub_dirs(Path)) + ec_file:is_dir(Path) andalso + lists:foreach(fun(ChildPath) -> + remove_links(ChildPath) + end, sub_dirs(Path)) end. +delete_dir_link(Path) -> + case os:type() of + {unix, _} -> file:delete(Path); + {win32, _} -> file:del_dir(Path) + end. + sub_dirs(Path) -> {ok, SubDirs} = file:list_dir(Path), [filename:join(Path, SubDir) || SubDir <- SubDirs]. -- cgit v1.1