Merge pull request #155 from paulo-ferraz-oliveira/feature/symlinks_in_copy

Keep symlinks in copies
This commit is contained in:
Fred Hebert 2021-04-09 21:17:36 -04:00 committed by GitHub
commit 26bcdf8030
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,7 +80,14 @@ copy(From, To) ->
copy_(From, To, [{file_info, [mode, time, owner, group]}]). copy_(From, To, [{file_info, [mode, time, owner, group]}]).
copy_(From, To, Options) -> copy_(From, To, Options) ->
case file:copy(From, To) of Linked
= case file:read_link(From) of
{ok, Linked0} -> Linked0;
{error, _} -> undefined
end,
case Linked =/= undefined orelse file:copy(From, To) of
true ->
file:make_symlink(Linked, To);
{ok, _} -> {ok, _} ->
copy_file_info(To, From, proplists:get_value(file_info, Options, [])); copy_file_info(To, From, proplists:get_value(file_info, Options, []));
{error, Error} -> {error, Error} ->