summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Gumm <sigmastar@gmail.com>2012-02-17 04:06:20 -0600
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-02-20 19:23:35 +0100
commit33546cc402aba5ab6ffe9f3b3002e7cf677761ff (patch)
tree9e85fe6b05614bff04af46c908fc2525ba599b97 /src
parent4f6f41cabba011b8f5d715c97a0a47cce51403ad (diff)
Fix copying dir to non-existing dir in Win32
Diffstat (limited to 'src')
-rw-r--r--src/rebar_file_utils.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index e3e7858..2a782f0 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -150,6 +150,25 @@ cp_r_win32({false, Source},{false, Dest}) ->
%% from file to file
{ok,_} = file:copy(Source, Dest),
ok;
+cp_r_win32({true, SourceDir}, {false, DestDir}) ->
+ case filelib:is_regular(DestDir) of
+ true ->
+ %% From directory to file? This shouldn't happen
+ {error, lists:flatten(
+ io_lib:format("Cannot copy dir (~p) to file (~p)\n",
+ [SourceDir, DestDir]))};
+ false ->
+ %% Specifying a target directory that doesn't currently exist.
+ %% So let's attempt to create this directory
+ case filelib:ensure_dir(filename:join(DestDir, "dummy")) of
+ ok ->
+ ok = xcopy_win32(SourceDir, DestDir);
+ {error, Reason} ->
+ {error, lists:flatten(
+ io_lib:format("Unable to create dir ~p: ~p\n",
+ [DestDir, Reason]))}
+ end
+ end;
cp_r_win32(Source,Dest) ->
Dst = {filelib:is_dir(Dest), Dest},
lists:foreach(fun(Src) ->