diff options
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/doc/src/file.xml | 4 | ||||
-rw-r--r-- | lib/kernel/src/file.erl | 25 |
2 files changed, 20 insertions, 9 deletions
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> Mode = read | write | append | exclusive | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed</v> + <v> Mode = read | write | append | exclusive | raw | binary | {delayed_write, Size, Delay} | delayed_write | {read_ahead, Size} | read_ahead | compressed | {encoding, Encoding}</v> <v> Size = Delay = int()</v> + <v> Encoding = latin1 | unicode | utf8 | utf16 | {utf16, Endian} | utf32 | {utf32, Endian}</v> + <v> 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 |