aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/doc/src/file.xml67
-rw-r--r--lib/kernel/test/file_SUITE.erl40
2 files changed, 96 insertions, 11 deletions
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 75fa32f702..66ecba1bf2 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -60,14 +60,6 @@
converted, why the Unicode mode for file names is not default on
systems having completely transparent file naming.</p>
- <note>
- <p>As of R14B01, the most basic file handling modules
- (<c>file</c>, <c>prim_file</c>, <c>filelib</c> and
- <c>filename</c>) accept raw file names, but the rest of OTP is not
- guaranteed to handle them, why Unicode file naming on systems
- where it is not default is still considered experimental.</p>
- </note>
-
<p>Raw file names is a new feature in OTP R14B01, which allows the
user to supply completely uninterpreted file names to the
underlying OS/filesystem. They are supplied as binaries, where it
@@ -512,7 +504,8 @@
<name name="list_dir" arity="1"/>
<fsummary>List files in a directory</fsummary>
<desc>
- <p>Lists all the files in a directory. Returns
+ <p>Lists all files in a directory, <b>except</b> files
+ with "raw" names. Returns
<c>{ok, <anno>Filenames</anno>}</c> if successful.
Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>.
<c><anno>Filenames</anno></c> is a list of
@@ -539,6 +532,31 @@
</desc>
</func>
<func>
+ <name name="list_dir_all" arity="1"/>
+ <fsummary>List all files in a directory</fsummary>
+ <desc>
+ <p>Lists all the files in a directory, including files with
+ "raw" names.
+ Returns <c>{ok, <anno>Filenames</anno>}</c> if successful.
+ Otherwise, it returns <c>{error, <anno>Reason</anno>}</c>.
+ <c><anno>Filenames</anno></c> is a list of
+ the names of all the files in the directory. The names are
+ not sorted.</p>
+ <p>Typical error reasons are:</p>
+ <taglist>
+ <tag><c>eacces</c></tag>
+ <item>
+ <p>Missing search or write permissions for <c><anno>Dir</anno></c>
+ or one of its parent directories.</p>
+ </item>
+ <tag><c>enoent</c></tag>
+ <item>
+ <p>The directory does not exist.</p>
+ </item>
+ </taglist>
+ </desc>
+ </func>
+ <func>
<name name="make_dir" arity="1"/>
<fsummary>Make a directory</fsummary>
<desc>
@@ -1423,10 +1441,41 @@
<fsummary>See what a link is pointing to</fsummary>
<desc>
<p>This function returns <c>{ok, <anno>Filename</anno>}</c> if
+ <c><anno>Name</anno></c> refers to a symbolic link that is
+ not a "raw" file name, or <c>{error, <anno>Reason</anno>}</c>
+ otherwise.
+ On platforms that do not support symbolic links, the return
+ value will be <c>{error,enotsup}</c>.</p>
+ <p>Typical error reasons:</p>
+ <taglist>
+ <tag><c>einval</c></tag>
+ <item>
+ <p><c><anno>Name</anno></c> does not refer to a symbolic link
+ or the name of the file that it refers to does not conform
+ to the expected encoding.</p>
+ </item>
+ <tag><c>enoent</c></tag>
+ <item>
+ <p>The file does not exist.</p>
+ </item>
+ <tag><c>enotsup</c></tag>
+ <item>
+ <p>Symbolic links are not supported on this platform.</p>
+ </item>
+ </taglist>
+ </desc>
+ </func>
+ <func>
+ <name name="read_link_all" arity="1"/>
+ <fsummary>See what a link is pointing to</fsummary>
+ <desc>
+ <p>This function returns <c>{ok, <anno>Filename</anno>}</c> if
<c><anno>Name</anno></c> refers to a symbolic link or
<c>{error, <anno>Reason</anno>}</c> otherwise.
On platforms that do not support symbolic links, the return
value will be <c>{error,enotsup}</c>.</p>
+ <p>Note that <c><anno>Filename</anno></c> can be either a list
+ or a binary.</p>
<p>Typical error reasons:</p>
<taglist>
<tag><c>einval</c></tag>
diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl
index f8887db34e..c604e7073f 100644
--- a/lib/kernel/test/file_SUITE.erl
+++ b/lib/kernel/test/file_SUITE.erl
@@ -45,7 +45,8 @@
init_per_testcase/2, end_per_testcase/2,
read_write_file/1, names/1]).
-export([cur_dir_0/1, cur_dir_1/1, make_del_dir/1,
- list_dir/1,list_dir_error/1, untranslatable_names/1,
+ list_dir/1,list_dir_error/1,
+ untranslatable_names/1, untranslatable_names_error/1,
pos1/1, pos2/1]).
-export([close/1, consult1/1, path_consult/1, delete/1]).
-export([ eval1/1, path_eval/1, script1/1, path_script/1,
@@ -117,7 +118,8 @@ all() ->
groups() ->
[{dirs, [], [make_del_dir, cur_dir_0, cur_dir_1,
- list_dir, list_dir_error, untranslatable_names]},
+ list_dir, list_dir_error, untranslatable_names,
+ untranslatable_names_error]},
{files, [],
[{group, open}, {group, pos}, {group, file_info},
{group, consult}, {group, eval}, {group, script},
@@ -598,6 +600,40 @@ untranslatable_names_1(Config) ->
end,
ok.
+untranslatable_names_error(Config) ->
+ case no_untranslatable_names() of
+ true ->
+ {skip,"Not a problem on this OS"};
+ false ->
+ untranslatable_names_error_1(Config)
+ end.
+
+untranslatable_names_error_1(Config) ->
+ {ok,OldCwd} = file:get_cwd(),
+ PrivDir = ?config(priv_dir, Config),
+ Dir = filename:join(PrivDir, "untranslatable_names_error"),
+ ok = file:make_dir(Dir),
+ Node = start_node(untranslatable_names, "+fnue"),
+ try
+ ok = file:set_cwd(Dir),
+ [ok = file:write_file(F, F) || {_,F} <- untranslatable_names()],
+
+ ExpectedListDir0 = [unicode:characters_to_list(N, utf8) ||
+ {utf8,N} <- untranslatable_names()],
+ ExpectedListDir = lists:sort(ExpectedListDir0),
+ io:format("ExpectedListDir: ~p\n", [ExpectedListDir]),
+ {error,{no_translation,BadFile}} =
+ rpc:call(Node, file, list_dir, [Dir]),
+ true = lists:keymember(BadFile, 2, untranslatable_names())
+
+ after
+ catch test_server:stop_node(Node),
+ file:set_cwd(OldCwd),
+ [file:delete(F) || {_,F} <- untranslatable_names()],
+ file:del_dir(Dir)
+ end,
+ ok.
+
untranslatable_names() ->
[{utf8,<<"abc">>},
{utf8,<<"def">>},