aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2012-08-20 17:08:40 +0200
committerFredrik Gustafsson <[email protected]>2012-08-20 17:08:40 +0200
commitf09b615c6a63aa336787be78bb932fc350a1bbc0 (patch)
tree99d67140a213bae7ae749ba2722015056a070289 /lib/stdlib
parent786122a8cb40fbf9cb7357071c1bf13bf51e7f3c (diff)
parent6a22e6b29f8d86318fc72feb8698046546868481 (diff)
downloadotp-f09b615c6a63aa336787be78bb932fc350a1bbc0.tar.gz
otp-f09b615c6a63aa336787be78bb932fc350a1bbc0.tar.bz2
otp-f09b615c6a63aa336787be78bb932fc350a1bbc0.zip
Merge branch 'jkl/fix-filename-nativename/OTP-10188' into maint
* jkl/fix-filename-nativename/OTP-10188: Fix filename:nativename/1 on Win32 Add filename:nativename/1 binary argument test to suite
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/filename.erl2
-rw-r--r--lib/stdlib/test/filename_SUITE.erl15
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index dbfcbea4f7..870af4e95f 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -726,6 +726,8 @@ nativename(Name0) ->
_ -> Name
end.
+win32_nativename(Name) when is_binary(Name) ->
+ binary:replace(Name, <<"/">>, <<"\\">>, [global]);
win32_nativename([$/|Rest]) ->
[$\\|win32_nativename(Rest)];
win32_nativename([C|Rest]) ->
diff --git a/lib/stdlib/test/filename_SUITE.erl b/lib/stdlib/test/filename_SUITE.erl
index 4cfa589660..99516c0c04 100644
--- a/lib/stdlib/test/filename_SUITE.erl
+++ b/lib/stdlib/test/filename_SUITE.erl
@@ -25,7 +25,7 @@
-export([pathtype/1,rootname/1,split/1,find_src/1]).
-export([absname_bin/1, absname_bin_2/1,
basename_bin_1/1, basename_bin_2/1,
- dirname_bin/1, extension_bin/1, join_bin/1]).
+ dirname_bin/1, extension_bin/1, join_bin/1, t_nativename_bin/1]).
-export([pathtype_bin/1,rootname_bin/1,split_bin/1]).
-include_lib("test_server/include/test_server.hrl").
@@ -38,7 +38,7 @@ all() ->
join, pathtype, rootname, split, t_nativename, find_src,
absname_bin, absname_bin_2, basename_bin_1, basename_bin_2, dirname_bin,
extension_bin,
- join_bin, pathtype_bin, rootname_bin, split_bin].
+ join_bin, pathtype_bin, rootname_bin, split_bin, t_nativename_bin].
groups() ->
[].
@@ -804,3 +804,14 @@ split_bin(Config) when is_list(Config) ->
ok
end.
+t_nativename_bin(Config) when is_list(Config) ->
+ ?line <<"abcedf">> = filename:nativename(<<"abcedf">>),
+ case os:type() of
+ {win32, _} ->
+ ?line <<"a:\\temp\\arne.exe">> =
+ filename:nativename(<<"A:/temp//arne.exe/">>);
+ _ ->
+ ?line <<"/usr/tmp/arne">> =
+ filename:nativename(<<"/usr/tmp//arne/">>)
+ end.
+