diff options
author | Kostis Sagonas <[email protected]> | 2010-02-14 17:08:05 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2010-03-07 13:26:35 +0100 |
commit | 8fef4ffec7245102407ccf73afb5c5c4a42a4ee3 (patch) | |
tree | b82ef911624292f28bbf9cf480dd9ae98e099dfd /lib/kernel/src | |
parent | da70b2b0eca09f572e3275240ba60f1da6b679c4 (diff) | |
download | otp-8fef4ffec7245102407ccf73afb5c5c4a42a4ee3.tar.gz otp-8fef4ffec7245102407ccf73afb5c5c4a42a4ee3.tar.bz2 otp-8fef4ffec7245102407ccf73afb5c5c4a42a4ee3.zip |
file.hrl: Move out type declarations
Having various type declarations in the file.hrl file was once upon a time
necessary since the system could not really handle remote types. Now it can
and these declarations should not be there but appear in file.erl instead.
This means that files that need to use these types can refer to them using
a remote type reference, and not having to include file.hrl - at least not
for this reason.
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/disk_log.hrl | 10 | ||||
-rw-r--r-- | lib/kernel/src/disk_log_1.erl | 6 | ||||
-rw-r--r-- | lib/kernel/src/file.erl | 9 | ||||
-rw-r--r-- | lib/kernel/src/wrap_log_reader.erl | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/lib/kernel/src/disk_log.hrl b/lib/kernel/src/disk_log.hrl index b0849145ca..4b40030bcf 100644 --- a/lib/kernel/src/disk_log.hrl +++ b/lib/kernel/src/disk_log.hrl @@ -44,17 +44,11 @@ -define(OPENED, <<6,7,8,9>>). -define(CLOSED, <<99,88,77,11>>). -%% Needed for the definition of fd() +%% Needed for the definition of #file_info{} %% Must use include_lib() so that we always can be sure to find %% file.hrl. A relative path will not work in an installed system. -include_lib("kernel/include/file.hrl"). -%% Ugly workaround. If we are building the bootstrap compiler, -%% file.hrl does not define the fd() type. --ifndef(FILE_HRL_). --type fd() :: pid() | #file_descriptor{}. --endif. - %%------------------------------------------------------------------------ %% Types -- alphabetically %%------------------------------------------------------------------------ @@ -94,7 +88,7 @@ options = [] :: dlog_options()}). -record(cache, %% Cache for logged terms (per file descriptor). - {fd :: fd(), %% File descriptor. + {fd :: file:fd(), %% File descriptor. sz = 0 :: non_neg_integer(), %% Number of bytes in the cache. c = [] :: iodata()} %% The cache. ). diff --git a/lib/kernel/src/disk_log_1.erl b/lib/kernel/src/disk_log_1.erl index 7103417149..25ed9ec275 100644 --- a/lib/kernel/src/disk_log_1.erl +++ b/lib/kernel/src/disk_log_1.erl @@ -1529,7 +1529,7 @@ write_cache(Fd, FileName, C) -> Error -> {catch file_error(FileName, Error), #cache{fd = Fd}} end. --spec write_cache_close(fd(), file:filename(), iodata()) -> #cache{}. % | throw(Error) +-spec write_cache_close(file:fd(), file:filename(), iodata()) -> #cache{}. % | throw(Error) write_cache_close(Fd, _FileName, []) -> #cache{fd = Fd}; @@ -1539,12 +1539,12 @@ write_cache_close(Fd, FileName, C) -> Error -> file_error_close(Fd, FileName, Error) end. --spec file_error(file:filename(), {'error', atom()}) -> no_return(). +-spec file_error(file:filename(), {'error', file:posix()}) -> no_return(). file_error(FileName, {error, Error}) -> throw({error, {file_error, FileName, Error}}). --spec file_error_close(fd(), file:filename(), {'error', atom()}) -> no_return(). +-spec file_error_close(file:fd(), file:filename(), {'error', file:posix()}) -> no_return(). file_error_close(Fd, FileName, {error, Error}) -> file:close(Fd), diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index a42771dfb6..46ffa9d708 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -74,15 +74,22 @@ %% data types -type filename() :: string(). -type file_info() :: #file_info{}. --type io_device() :: pid() | #file_descriptor{}. +-type fd() :: #file_descriptor{}. +-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'. +-type name() :: string() | atom() | [name()]. +-type posix() :: atom(). -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()}. + %%%----------------------------------------------------------------- %%% General functions diff --git a/lib/kernel/src/wrap_log_reader.erl b/lib/kernel/src/wrap_log_reader.erl index 5030d3aed5..7ad4de52a8 100644 --- a/lib/kernel/src/wrap_log_reader.erl +++ b/lib/kernel/src/wrap_log_reader.erl @@ -37,7 +37,7 @@ cont :: dlog_cont(), % disk_log's continuation record file :: file:filename(), % file name without extension file_no :: non_neg_integer(), % current file number - mod_time :: date_time(), % modification time of current file + mod_time :: file:date_time(), % modification time of current file first_no :: non_neg_integer() | 'one' % first read file number }). |