aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremtenet <[email protected]>2016-04-24 13:41:17 +1000
committerTino Breddin <[email protected]>2019-04-16 15:54:56 +0200
commit9d47ab01be9819e0f69f7da73c71c34903f5b911 (patch)
tree8a068d4f9e9ce139ee2e74de642d9fad50b9af1b
parent8ff1e44cebf3aee09969a9324c04074ba87f10b9 (diff)
downloadrelx-9d47ab01be9819e0f69f7da73c71c34903f5b911.tar.gz
relx-9d47ab01be9819e0f69f7da73c71c34903f5b911.tar.bz2
relx-9d47ab01be9819e0f69f7da73c71c34903f5b911.zip
Remove dead code of cp_r/2, xcopy_win32/2 and cp_r_win32/2.
The bulk of the code is hidden behind opposite checks: * os:type() /= {win32, _} in symlink_or_copy/2 * os:type() == {win32, _} in cp_r/2 symlink_or_copy/2 is always using win32_symlink/2 when file:make_symlink/2 fails.
-rw-r--r--src/rlx_util.erl64
1 files changed, 2 insertions, 62 deletions
diff --git a/src/rlx_util.erl b/src/rlx_util.erl
index b3fc2b7..f68c291 100644
--- a/src/rlx_util.erl
+++ b/src/rlx_util.erl
@@ -233,18 +233,14 @@ symlink_or_copy(Source, Target) ->
ok;
{error, eexist} ->
{error, eexist};
- {error, _} ->
+ {error, _} = Error ->
case os:type() of
{win32, _} ->
S = unicode:characters_to_list(Source),
T = unicode:characters_to_list(Target),
win32_symlink(filename:nativename(S), filename:nativename(T));
_ ->
- case filelib:is_dir(Target) of
- true -> ok;
- false ->
- cp_r([Source], Target)
- end
+ Error
end
end.
@@ -253,62 +249,6 @@ win32_symlink(Source, Target) ->
os:cmd("cmd /c mklink /j " ++ Target ++ " " ++ Source),
ok.
--spec cp_r(list(string()), file:filename()) -> 'ok'.
-cp_r(Sources, Dest) ->
- case os:type() of
- {unix, _} ->
- ok;
- {win32, _} ->
- lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),
- ok
- end.
-
-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.
- os:cmd("robocopy " ++ Source ++ " " ++ Dest ++ " /e /is"),
- ok.
-
-cp_r_win32({true, SourceDir}, {true, DestDir}) ->
- %% from directory to directory
- ok = case file:make_dir(DestDir) of
- {error, eexist} -> ok;
- Other -> Other
- end,
- ok = xcopy_win32(SourceDir, DestDir);
-cp_r_win32({false, Source} = S,{true, DestDir}) ->
- %% from file to directory
- cp_r_win32(S, {false, filename:join(DestDir, filename:basename(Source))});
-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) ->
- ok = cp_r_win32({filelib:is_dir(Src), Src}, Dst)
- end, filelib:wildcard(Source)),
- ok.
-
%% @doc Returns the color intensity, we first check the application envorinment
%% if that is not set we check the environment variable RELX_COLOR.
intensity() ->