Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for cp_r_win32 where copying a directory to a non-existant directory would crash #187

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/rebar_file_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ cp_r_win32({false, Source},{false, Dest}) ->
%% from file to file
{ok,_} = file:copy(Source, Dest),
ok;
cp_r_win32({true, SourceDir},{false,DestDir}) ->
IsFile = filelib:is_file(DestDir),
case IsFile of
true ->
%% From Directory to file? This shouldn't happen
{error,[{rebar_file_utils,cp_r_win32},
{directory_to_file_makes_no_sense,
{source,SourceDir},{dest,DestDir}}]};
false ->
%% Specifying a target directory that doesn't currently exist.
%% So Let's attempt to create this directory
%% Will not recursively create parent directories
ok = case file:make_dir(DestDir) of
{error, eexist} -> ok;
Other -> Other
end,
ok = xcopy_win32(SourceDir, DestDir)
end;
cp_r_win32(Source,Dest) ->
Dst = {filelib:is_dir(Dest), Dest},
lists:foreach(fun(Src) ->
Expand Down