aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/include/file.hrl31
-rw-r--r--lib/kernel/src/disk_log.hrl10
-rw-r--r--lib/kernel/src/disk_log_1.erl6
-rw-r--r--lib/kernel/src/file.erl9
-rw-r--r--lib/kernel/src/wrap_log_reader.erl2
5 files changed, 23 insertions, 35 deletions
diff --git a/lib/kernel/include/file.hrl b/lib/kernel/include/file.hrl
index c1de4d764d..9279c74eb6 100644
--- a/lib/kernel/include/file.hrl
+++ b/lib/kernel/include/file.hrl
@@ -21,29 +21,18 @@
-define(FILE_HRL_, 1).
%%--------------------------------------------------------------------------
-%%-type namelist() :: [char() | atom() | namelist()].
--type namelist() :: [_]. %% XXX: GROSS OVERAPPROXIMATION -- FIX ME
--type name() :: string() | atom() | namelist().
--type posix() :: atom().
-
--type date() :: {pos_integer(), pos_integer(), pos_integer()}.
--type time() :: {non_neg_integer(), non_neg_integer(), non_neg_integer()}.
--type date_time() :: {date(), time()}.
-
-%%--------------------------------------------------------------------------
-
-record(file_info,
{size :: non_neg_integer(), % Size of file in bytes.
type :: 'device' | 'directory' | 'other' | 'regular' | 'symlink',
access :: 'read' | 'write' | 'read_write' | 'none',
- atime :: date_time(), % The local time the file was last read:
- % {{Year, Mon, Day}, {Hour, Min, Sec}}.
- mtime :: date_time(), % The local time the file was last written.
- ctime :: date_time(), % The interpretation of this time field
- % is dependent on operating system.
- % On Unix it is the last time the file or
- % or the inode was changed. On Windows,
- % it is the creation time.
+ atime :: file:date_time(), % The local time the file was last read:
+ % {{Year, Mon, Day}, {Hour, Min, Sec}}.
+ mtime :: file:date_time(), % The local time the file was last written.
+ ctime :: file:date_time(), % The interpretation of this time field
+ % is dependent on operating system.
+ % On Unix it is the last time the file
+ % or the inode was changed. On Windows,
+ % it is the creation time.
mode :: integer(), % File permissions. On Windows,
% the owner permissions will be
% duplicated for group and user.
@@ -61,10 +50,8 @@
-record(file_descriptor,
- {module :: module(), % Module that handles this kind of file
+ {module :: module(), % Module that handles this kind of file
data :: term()}). % Module dependent data
--type fd() :: pid() | #file_descriptor{}.
-
%%--------------------------------------------------------------------------
-endif.
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
}).