From 82f8c6e3c18716672f09428f9b8f57337e3585e0 Mon Sep 17 00:00:00 2001 From: yida_young <418621207@qq.com> Date: Mon, 19 Oct 2020 11:46:49 +0800 Subject: [PATCH] Fix compile issue on windows when language is not english --- src/rebar_file_utils.erl | 12 ++++++++---- src/rebar_utils.erl | 12 ++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index f01c9d32..df4d1b5a 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -163,13 +163,17 @@ win32_mklink_ok({error,{1,"Cannot create a file when that file already exists.\n % File or dir is already in place; find if it is already a symlink (true) or % if it is a directory (copy-required; false) is_symlink(Target); -win32_mklink_ok(_, _) -> - false. +win32_mklink_ok(_, Target) -> + is_symlink(Target). %% @private is_symlink(Filename) -> - {ok, Info} = file:read_link_info(Filename), - Info#file_info.type == symlink. + case file:read_link_info(Filename) of + {ok, Info} -> + Info#file_info.type == symlink; + _ -> + false + end. %% @private %% drops the last 'node' of the filename, presumably the last dir such as 'src' diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 70bbcd22..cecb399e 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -675,12 +675,20 @@ debug_and_abort(Command, {Rc, Output}) -> "~ts", [Command, Rc, Output]), throw(rebar_abort). +port_line_to_list(Line) -> + case unicode:characters_to_list(Line) of + LineList when is_list(LineList) -> + LineList; + _ -> + binary_to_list(Line) + end. + sh_loop(Port, Fun, Acc) -> receive {Port, {data, {eol, Line}}} -> - sh_loop(Port, Fun, Fun(unicode:characters_to_list(Line) ++ "\n", Acc)); + sh_loop(Port, Fun, Fun(port_line_to_list(Line) ++ "\n", Acc)); {Port, {data, {noeol, Line}}} -> - sh_loop(Port, Fun, Fun(unicode:characters_to_list(Line), Acc)); + sh_loop(Port, Fun, Fun(port_line_to_list(Line), Acc)); {Port, eof} -> Data = lists:flatten(lists:reverse(Acc)), receive