aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/c.erl
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-10-14 10:12:57 +0200
committerPatrik Nyblom <[email protected]>2010-11-30 16:29:05 +0100
commit63eeba2f6829aac2644eaf212ebef9cdf4b59e8d (patch)
treef5dd68d6626e30fe1e86ac312c60fc23c8120c0f /lib/stdlib/src/c.erl
parenta3ad23a50ef3dbdb8309bd178014d3285d87a78f (diff)
downloadotp-63eeba2f6829aac2644eaf212ebef9cdf4b59e8d.tar.gz
otp-63eeba2f6829aac2644eaf212ebef9cdf4b59e8d.tar.bz2
otp-63eeba2f6829aac2644eaf212ebef9cdf4b59e8d.zip
Handle binary file names and conversion of unicode strings
Diffstat (limited to 'lib/stdlib/src/c.erl')
-rw-r--r--lib/stdlib/src/c.erl20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/stdlib/src/c.erl b/lib/stdlib/src/c.erl
index 6d50a575eb..399b91b92f 100644
--- a/lib/stdlib/src/c.erl
+++ b/lib/stdlib/src/c.erl
@@ -659,7 +659,7 @@ portformat(Name, Id, Cmd) ->
pwd() ->
case file:get_cwd() of
{ok, Str} ->
- ok = io:format("~s\n", [Str]);
+ ok = io:format("~s\n", [fixup_one_bin(Str)]);
{error, _} ->
ok = io:format("Cannot determine current directory\n")
end.
@@ -684,11 +684,27 @@ ls() ->
ls(Dir) ->
case file:list_dir(Dir) of
{ok, Entries} ->
- ls_print(sort(Entries));
+ ls_print(sort(fixup_bin(Entries)));
{error,_E} ->
format("Invalid directory\n")
end.
+fixup_one_bin(X) when is_binary(X) ->
+ L = binary_to_list(X),
+ [ if
+ El > 127 ->
+ $?;
+ true ->
+ El
+ end || El <- L];
+fixup_one_bin(X) ->
+ X.
+fixup_bin([H|T]) ->
+ [fixup_one_bin(H) | fixup_bin(T)];
+fixup_bin([]) ->
+ [].
+
+
ls_print([]) -> ok;
ls_print(L) ->
Width = min([max(lengths(L, [])), 40]) + 5,