mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Fix copying dir to non-existing dir in Win32
This commit is contained in:
parent
4f6f41cabb
commit
33546cc402
1 changed files with 19 additions and 0 deletions
|
@ -150,6 +150,25 @@ cp_r_win32({false, Source},{false, Dest}) ->
|
||||||
%% from file to file
|
%% from file to file
|
||||||
{ok,_} = file:copy(Source, Dest),
|
{ok,_} = file:copy(Source, Dest),
|
||||||
ok;
|
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) ->
|
cp_r_win32(Source,Dest) ->
|
||||||
Dst = {filelib:is_dir(Dest), Dest},
|
Dst = {filelib:is_dir(Dest), Dest},
|
||||||
lists:foreach(fun(Src) ->
|
lists:foreach(fun(Src) ->
|
||||||
|
|
Loading…
Reference in a new issue