aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/hipe/cerl/erl_bif_types.erl8
-rw-r--r--lib/kernel/doc/src/file.xml4
-rw-r--r--lib/kernel/src/file.erl25
-rw-r--r--lib/stdlib/src/unicode.erl11
4 files changed, 30 insertions, 18 deletions
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl
index 835f9a205a..696414eb7a 100644
--- a/lib/hipe/cerl/erl_bif_types.erl
+++ b/lib/hipe/cerl/erl_bif_types.erl
@@ -2001,12 +2001,6 @@ type(file, get_cwd, 0, _) ->
t_tuple([t_atom('error'), t_file_posix_error()]));
type(file, make_dir, 1, Xs) ->
strict(arg_types(file, make_dir, 1), Xs, fun (_) -> t_file_return() end);
-type(file, open, 2, Xs) ->
- strict(arg_types(file, open, 2), Xs,
- fun (_) ->
- t_sup([t_tuple([t_atom('ok'), t_file_io_device()]),
- t_tuple([t_atom('error'), t_file_posix_error()])])
- end);
type(file, read_file, 1, Xs) ->
strict(arg_types(file, read_file, 1), Xs,
fun (_) ->
@@ -4214,8 +4208,6 @@ arg_types(file, get_cwd, 0) ->
[];
arg_types(file, make_dir, 1) ->
[t_file_name()];
-arg_types(file, open, 2) ->
- [t_file_name(), t_list(t_file_open_option())];
arg_types(file, read_file, 1) ->
[t_file_name()];
arg_types(file, set_cwd, 1) ->
diff --git a/lib/kernel/doc/src/file.xml b/lib/kernel/doc/src/file.xml
index 2044b074ee..64cdd3a8ea 100644
--- a/lib/kernel/doc/src/file.xml
+++ b/lib/kernel/doc/src/file.xml
@@ -603,8 +603,10 @@ f.txt: {person, "kalle", 25}.
<type>
<v>Filename = name()</v>
<v>Modes = [Mode]</v>
- <v>&nbsp;Mode = read | write | append | exclusive | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed</v>
+ <v>&nbsp;Mode = read | write | append | exclusive | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed | {encoding, Encoding}</v>
<v>&nbsp;&nbsp;Size = Delay = int()</v>
+ <v>&nbsp;&nbsp;Encoding = latin1 | unicode | utf8 | utf16 | {utf16, Endian} | utf32 | {utf32, Endian}</v>
+ <v>&nbsp;&nbsp;&nbsp;&nbsp;Endian = big | little</v>
<v>IoDevice = io_device()</v>
<v>Reason = ext_posix() | system_limit</v>
</type>
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index cffe4e3db5..97d914b043 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -81,19 +81,28 @@
-type io_device() :: pid() | fd().
-type location() :: integer() | {'bof', integer()} | {'cur', integer()}
| {'eof', integer()} | 'bof' | 'cur' | 'eof'.
--type mode() :: 'read' | 'write' | 'append' | 'raw' | 'binary' |
- {'delayed_write', non_neg_integer(), non_neg_integer()} |
- 'delayed_write' | {'read_ahead', pos_integer()} |
- 'read_ahead' | 'compressed' | 'exclusive'.
+-type mode() :: 'read' | 'write' | 'append'
+ | 'exclusive' | 'raw' | 'binary'
+ | {'delayed_write', non_neg_integer(), non_neg_integer()}
+ | 'delayed_write' | {'read_ahead', pos_integer()}
+ | 'read_ahead' | 'compressed'
+ | {'encoding', unicode:encoding()}.
-type name() :: string() | atom() | [name()].
--type posix() :: atom().
+-type posix() :: 'eacces' | 'eagain' | 'ebadf' | 'ebusy' | 'edquot'
+ | 'eexist' | 'efault' | 'efbig' | 'eintr' | 'einval'
+ | 'eio' | 'eisdir' | 'eloop' | 'emfile' | 'emlink'
+ | 'enametoolong'
+ | 'enfile' | 'enodev' | 'enoent' | 'enomem' | 'enospc'
+ | 'enotblk' | 'enotdir' | 'enotsup' | 'enxio' | 'eperm'
+ | 'epipe' | 'erofs' | 'espipe' | 'esrch' | 'estale'
+ | 'exdev'.
-type bindings() :: any().
-type date() :: {pos_integer(), pos_integer(), pos_integer()}.
-type time() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}.
-type date_time() :: {date(), time()}.
--type posix_file_advise() :: 'normal' | 'sequential' | 'random' | 'no_reuse' |
- 'will_need' | 'dont_need'.
+-type posix_file_advise() :: 'normal' | 'sequential' | 'random'
+ | 'no_reuse' | 'will_need' | 'dont_need'.
%%%-----------------------------------------------------------------
%%% General functions
@@ -286,7 +295,7 @@ raw_write_file_info(Name, #file_info{} = Info) ->
%% Contemporary mode specification - list of options
-spec open(Name :: name(), Modes :: [mode()]) ->
- {'ok', io_device()} | {'error', posix()}.
+ {'ok', io_device()} | {'error', posix() | 'system_limit'}.
open(Item, ModeList) when is_list(ModeList) ->
case lists:member(raw, ModeList) of
diff --git a/lib/stdlib/src/unicode.erl b/lib/stdlib/src/unicode.erl
index 09b1deff9c..869505ba83 100644
--- a/lib/stdlib/src/unicode.erl
+++ b/lib/stdlib/src/unicode.erl
@@ -25,8 +25,17 @@
%% InEncoding is not {latin1 | unicode | utf8})
%%
--export([characters_to_list/1, characters_to_list_int/2, characters_to_binary/1,characters_to_binary_int/2, characters_to_binary/3,bom_to_encoding/1, encoding_to_bom/1]).
+-export([characters_to_list/1, characters_to_list_int/2,
+ characters_to_binary/1, characters_to_binary_int/2,
+ characters_to_binary/3,
+ bom_to_encoding/1, encoding_to_bom/1]).
+-export_type([encoding/0]).
+
+-type encoding() :: 'latin1' | 'unicode' | 'utf8'
+ | 'utf16' | {'utf16', endian()}
+ | 'utf32' | {'utf32', endian()}.
+-type endian() :: 'big' | 'little'.
characters_to_list(ML) ->
unicode:characters_to_list(ML,unicode).