aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/filename.erl
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-10-12 16:30:38 +0200
committerRickard Green <[email protected]>2017-10-12 16:30:38 +0200
commit55693961fbb6371d2c3ec0a426f30b8acace6ed1 (patch)
tree7debd0d509349e26508c211763f1865652c623ef /lib/stdlib/src/filename.erl
parent4900f9886cc80ecf34f9590829878da937e75422 (diff)
parentf28539265d753bbaa473cb488e951bfe47304a01 (diff)
downloadotp-55693961fbb6371d2c3ec0a426f30b8acace6ed1.tar.gz
otp-55693961fbb6371d2c3ec0a426f30b8acace6ed1.tar.bz2
otp-55693961fbb6371d2c3ec0a426f30b8acace6ed1.zip
Merge branch 'maint'
* maint: Revert "Merge branch 'rickard/null-char-filenames/ERL-370/OTP-14543' into maint"
Diffstat (limited to 'lib/stdlib/src/filename.erl')
-rw-r--r--lib/stdlib/src/filename.erl70
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index 73eccb226e..63cfeae57b 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -41,7 +41,6 @@
safe_relative_path/1]).
-export([find_src/1, find_src/2]). % deprecated
-export([basedir/2, basedir/3]).
--export([validate/1]).
%% Undocumented and unsupported exports.
-export([append/2]).
@@ -1136,72 +1135,3 @@ basedir_os_type() ->
{win32,_} -> windows;
_ -> linux
end.
-
-%%
-%% validate/1
-%%
-
--spec validate(FileName) -> boolean() when
- FileName :: file:name_all().
-
-validate(FileName) when is_binary(FileName) ->
- %% Raw filename...
- validate_bin(FileName);
-validate(FileName) when is_list(FileName);
- is_atom(FileName) ->
- validate_list(FileName,
- file:native_name_encoding(),
- os:type()).
-
-validate_list(FileName, Enc, Os) ->
- try
- true = validate_list(FileName, Enc, Os, 0) > 0
- catch
- _ : _ -> false
- end.
-
-validate_list([], _Enc, _Os, Chars) ->
- Chars;
-validate_list(C, Enc, Os, Chars) when is_integer(C) ->
- validate_char(C, Enc, Os),
- Chars+1;
-validate_list(A, Enc, Os, Chars) when is_atom(A) ->
- validate_list(atom_to_list(A), Enc, Os, Chars);
-validate_list([H|T], Enc, Os, Chars) ->
- NewChars = validate_list(H, Enc, Os, Chars),
- validate_list(T, Enc, Os, NewChars).
-
-%% C is always an integer...
-% validate_char(C, _, _) when not is_integer(C) ->
-% throw(invalid);
-validate_char(C, _, _) when C < 1 ->
- throw(invalid); %% No negative or null characters...
-validate_char(C, latin1, _) when C > 255 ->
- throw(invalid);
-validate_char(C, utf8, _) when C >= 16#110000 ->
- throw(invalid);
-validate_char(C, utf8, {win32, _}) when C > 16#ffff ->
- throw(invalid); %% invalid win wchar...
-validate_char(_C, utf8, {win32, _}) ->
- ok; %% Range below is accepted on windows...
-validate_char(C, utf8, _) when 16#D800 =< C, C =< 16#DFFF ->
- throw(invalid); %% invalid unicode range...
-validate_char(_, _, _) ->
- ok.
-
-validate_bin(Bin) ->
- %% Raw filename. That is, we do not interpret
- %% the encoding, but we still do not accept
- %% null characters...
- try
- true = validate_bin(Bin, 0) > 0
- catch
- _ : _ -> false
- end.
-
-validate_bin(<<>>, Bs) ->
- Bs;
-validate_bin(<<0, _Rest/binary>>, _Bs) ->
- throw(invalid); %% No null characters allowed...
-validate_bin(<<_B, Rest/binary>>, Bs) ->
- validate_bin(Rest, Bs+1).