From 299fe33e3990074c596da7b90a90c83676d1f8fb Mon Sep 17 00:00:00 2001 From: CarlosEDP Date: Wed, 1 Jul 2015 10:48:09 -0300 Subject: Fix for robocopy command --- src/rebar_file_utils.erl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 3fc5698..3f60ef9 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -156,7 +156,7 @@ mv(Source, Dest) -> ok; {win32, _} -> Res = rebar_utils:sh( - ?FMT("robocopy /move /s \"~s\" \"~s\" 1> nul", + ?FMT("robocopy \"~s\" \"~s\" /move /s 1> nul", [filename:nativename(Source), filename:nativename(Dest)]), [{use_stdout, false}, return_on_error]), @@ -250,8 +250,13 @@ xcopy_win32(Source,Dest)-> %% "xcopy \"~s\" \"~s\" /q /y /e 2> nul", Chanegd to robocopy to %% handle long names. May have issues with older windows. Res = rebar_utils:sh( - ?FMT("robocopy \"~s\" \"~s\" /e /is /purge 2> nul", - [filename:nativename(Source), filename:nativename(Dest)]), + ?FMT("robocopy \"~s\" \"~s\" \"~s\" /e /is /purge 2> nul", + [filename:nativename(filename:dirname(Source)), + filename:nativename(Dest), + filename:basename(Source)]), + + % ?FMT("robocopy \"~s\" \"~s\" /e /is /purge 2> nul", + % [filename:nativename(Source), filename:nativename(Dest)]), [{use_stdout, false}, return_on_error]), case win32_ok(Res) of true -> ok; -- cgit v1.1 From 6d3fa8dd661f562b09c0be614b732939b5fe3c53 Mon Sep 17 00:00:00 2001 From: CarlosEDP Date: Wed, 1 Jul 2015 14:56:55 -0300 Subject: Fix for different robocopy behaviour when moving files or folders. --- src/rebar_file_utils.erl | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 3f60ef9..073d189 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -155,10 +155,18 @@ mv(Source, Dest) -> [{use_stdout, false}, abort_on_error]), ok; {win32, _} -> - Res = rebar_utils:sh( - ?FMT("robocopy \"~s\" \"~s\" /move /s 1> nul", + case filelib:is_dir(Source) of + true -> + Cmd = ?FMT("robocopy /move /s \"~s\" \"~s\" 1> nul", [filename:nativename(Source), - filename:nativename(Dest)]), + filename:nativename(Dest)]); + false -> + Cmd = ?FMT("robocopy /move /s \"~s\" \"~s\" \"~s\" 1> nul", + [filename:nativename(filename:dirname(Source)), + filename:nativename(Dest), + filename:basename(Source)]) + end, + Res = rebar_utils:sh(Cmd, [{use_stdout, false}, return_on_error]), case win32_ok(Res) of true -> ok; @@ -249,14 +257,18 @@ delete_each_dir_win32([Dir | Rest]) -> xcopy_win32(Source,Dest)-> %% "xcopy \"~s\" \"~s\" /q /y /e 2> nul", Chanegd to robocopy to %% handle long names. May have issues with older windows. - Res = rebar_utils:sh( - ?FMT("robocopy \"~s\" \"~s\" \"~s\" /e /is /purge 2> nul", - [filename:nativename(filename:dirname(Source)), - filename:nativename(Dest), - filename:basename(Source)]), - - % ?FMT("robocopy \"~s\" \"~s\" /e /is /purge 2> nul", - % [filename:nativename(Source), filename:nativename(Dest)]), + case filelib:is_dir(Source) of + true -> + Cmd = ?FMT("robocopy \"~s\" \"~s\" /e /is 1> nul", + [filename:nativename(Source), + filename:nativename(Dest)]); + false -> + Cmd = ?FMT("robocopy \"~s\" \"~s\" \"~s\" /e /is 1> nul", + [filename:nativename(filename:dirname(Source)), + filename:nativename(Dest), + filename:basename(Source)]) + end, + Res = rebar_utils:sh(Cmd, [{use_stdout, false}, return_on_error]), case win32_ok(Res) of true -> ok; -- cgit v1.1