Przeglądaj źródła

Fix windows-related issues

pull/489/head
Viacheslav V. Kovalev 10 lat temu
committed by Daniel Widgren
rodzic
commit
9ad39c979a
2 zmienionych plików z 24 dodań i 16 usunięć
  1. +9
    -6
      src/rebar_file_utils.erl
  2. +15
    -10
      src/rebar_prv_common_test.erl

+ 9
- 6
src/rebar_file_utils.erl Wyświetl plik

@ -120,21 +120,24 @@ mv(Source, Dest) ->
[{use_stdout, false}, abort_on_error]),
ok;
{win32, _} ->
{ok, R} = rebar_utils:sh(
?FMT("move /y \"~s\" \"~s\" 1> nul",
Res = rebar_utils:sh(
?FMT("robocopy /move /e \"~s\" \"~s\" 1> nul",
[filename:nativename(Source),
filename:nativename(Dest)]),
[{use_stdout, false}, return_on_error]),
case R of
[] ->
ok;
_ ->
case win32_robocopy_ok(Res) of
true -> ok;
false ->
{error, lists:flatten(
io_lib:format("Failed to move ~s to ~s~n",
[Source, Dest]))}
end
end.
win32_robocopy_ok({ok, _}) -> true;
win32_robocopy_ok({error, {Rc, _}}) when Rc<9, Rc==16 -> true;
win32_robocopy_ok(_) -> false.
delete_each([]) ->
ok;
delete_each([File | Rest]) ->

+ 15
- 10
src/rebar_prv_common_test.erl Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz