Skip to content

Commit

Permalink
file: Refactor io_device type
Browse files Browse the repository at this point in the history
  • Loading branch information
garazdawi committed Oct 17, 2024
1 parent 90fc71f commit f3f5872
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 9 additions & 3 deletions lib/kernel/src/file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ operating system kernel.

%% Types that can be used from other modules -- alphabetically ordered.
-export_type([date_time/0, fd/0, file_info/0, filename/0, filename_all/0,
io_device/0, location/0, mode/0, name/0, name_all/0, posix/0]).
io_device/0, io_server/0, location/0, mode/0, name/0, name_all/0, posix/0]).

%%% Includes and defines
-include("file_int.hrl").
Expand All @@ -264,8 +264,14 @@ See the documentation of the `t:name_all/0` type.".
-type file_descriptor() :: #file_descriptor{}.
-doc "A file descriptor representing a file opened in [`raw`](`m:file#raw`) mode.".
-type fd() :: file_descriptor().
-doc "As returned by `open/2`; `t:pid/0` is a process handling I/O-protocols.".
-type io_device() :: pid() | fd().
-doc "A process handling the I/O protocol.".
-type io_server() :: pid().
-doc """
An IO device as returned by `open/2`.
`t:io_server/0` is returned by default and `t:fd/0` is returned if the `raw` option is given.
""".
-type io_device() :: io_server() | fd().
-type location() :: integer() | {'bof', Offset :: integer()}
| {'cur', Offset :: integer()}
| {'eof', Offset :: integer()} | 'bof' | 'cur' | 'eof'.
Expand Down
10 changes: 5 additions & 5 deletions lib/stdlib/src/io.erl
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ handled by `user`.
""".
-type user() :: user.
-doc """
An I/O device, either `standard_io`, `standard_error`, `user`, a registered
name, or a pid handling I/O protocols (returned from `file:open/2`).
An I/O device, either `t:standard_io/0`, `t:standard_error/0`, `t:user/0`, a `t:file:io_server/0`,
a registered name, or any pid handling I/O protocols.
""".
-type device() :: atom() | pid() | standard_io() | standard_error() | user().
-type device() :: atom() | pid() | file:io_server() | standard_io() | standard_error() | user().
-type prompt() :: atom() | unicode:chardata().

%% ErrorDescription is whatever the I/O-server sends.
Expand Down Expand Up @@ -494,8 +494,8 @@ The options and values supported by the OTP I/O devices are as follows:
functions can handle any of these modes and so should other, user-written,
modules behaving as clients to I/O servers.
This option is supported by the standard shell (`group.erl`), the 'oldshell'
(`user.erl`), and the file I/O servers.
This option is supported by the `t:standard_io/0`, `t:user/0` and `t:file:io_server/0`
I/O servers.
- **`{echo, boolean()}`** - Denotes if the terminal is to echo input. Only
supported for the standard shell I/O server (`group.erl`)
Expand Down

0 comments on commit f3f5872

Please sign in to comment.