aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/src')
-rw-r--r--lib/kernel/src/file.erl135
-rw-r--r--lib/kernel/src/file_server.erl9
2 files changed, 84 insertions, 60 deletions
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index dafd2c6909..d8ade07336 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -31,7 +31,8 @@
read_file_info/1, read_file_info/2,
write_file_info/2, write_file_info/3,
altname/1,
- read_link_info/1, read_link_info/2, read_link/1,
+ read_link_info/1, read_link_info/2,
+ read_link/1,
make_link/2, make_symlink/2,
read_file/1, write_file/2, write_file/3]).
%% Specialized
@@ -213,10 +214,16 @@ del_dir(Name) ->
Reason :: posix() | badarg.
read_file_info(Name) ->
- file_info_time(local, check_and_call(read_file_info, [file_name(Name)])).
+ check_and_call(read_file_info, [file_name(Name)]).
+
+-spec read_file_info(Filename, Opts) -> {ok, FileInfo} | {error, Reason} when
+ Filename :: name(),
+ Opts :: list(),
+ FileInfo :: file_info(),
+ Reason :: posix() | badarg.
read_file_info(Name, Opts) when is_list(Opts) ->
- file_info_time(proplists:get_value(time, Opts, local), check_and_call(read_file_info, [file_name(Name)])).
+ check_and_call(read_file_info, [file_name(Name), Opts]).
-spec altname(Name :: name()) -> any().
@@ -229,10 +236,11 @@ altname(Name) ->
Reason :: posix() | badarg.
read_link_info(Name) ->
- read_link_info(Name, [{time, local}]).
+ check_and_call(read_link_info, [file_name(Name)]).
read_link_info(Name, Opts) when is_list(Opts) ->
- file_info_time(proplists:get_value(time, Opts, local), check_and_call(read_link_info, [file_name(Name)])).
+ check_and_call(read_link_info, [file_name(Name),Opts]).
+
-spec read_link(Name) -> {ok, Filename} | {error, Reason} when
Name :: name(),
@@ -248,10 +256,17 @@ read_link(Name) ->
Reason :: posix() | badarg.
write_file_info(Name, Info = #file_info{}) ->
- check_and_call(write_file_info, [file_name(Name), file_info_epochs(local, Info)]).
+ check_and_call(write_file_info, [file_name(Name), Info]).
+
+-spec write_file_info(Filename, FileInfo, Opts) -> ok | {error, Reason} when
+ Filename :: name(),
+ Opts :: list(),
+ FileInfo :: file_info(),
+ Reason :: posix() | badarg.
+
write_file_info(Name, Info = #file_info{}, Opts) when is_list(Opts) ->
- check_and_call(write_file_info, [file_name(Name), file_info_epochs(proplists:get_value(time, Opts, local), Info)]).
+ check_and_call(write_file_info, [file_name(Name), Info, Opts]).
-spec list_dir(Dir) -> {ok, Filenames} | {error, Reason} when
Dir :: name(),
@@ -1335,59 +1350,59 @@ fname_join(Dir, Name) ->
%% all times from prime_file (and file_server) are in unix epochs
%% from_epochs
-file_info_time(epoch, {ok, FI} = R) -> R;
-file_info_time(local, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
- {ok, FI#file_info{
- atime = time_epochs_to_local(Atime),
- ctime = time_epochs_to_local(Ctime),
- mtime = time_epochs_to_local(Mtime)
- }
- };
-file_info_time(utc, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
- {ok, FI#file_info{
- atime = time_epochs_to_utc(Atime),
- ctime = time_epochs_to_utc(Ctime),
- mtime = time_epochs_to_utc(Mtime)
- }
- };
-file_info_time(_, Error) -> Error.
-
-%% from_epochs
-file_info_epochs(epoch, FI) -> FI;
-file_info_epochs(local, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI) ->
- FI#file_info{
- atime = time_local_to_epochs(Atime),
- ctime = time_local_to_epochs(Ctime),
- mtime = time_local_to_epochs(Mtime)
- };
-file_info_epochs(utc, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
- FI#file_info{
- atime = time_utc_to_epochs(Atime),
- ctime = time_utc_to_epochs(Ctime),
- mtime = time_utc_to_epochs(Mtime)
- }.
-
-
--define(DAYS_FROM_0_TO_1970, 719528).
--define(SECONDS_PER_DAY, 86400).
-
-time_epochs_to_utc(Seconds) when is_integer(Seconds) ->
- calendar:gregorian_seconds_to_datetime(Seconds + ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970).
-
-time_epochs_to_local(Seconds) when is_integer(Seconds) ->
- erlang:universaltime_to_localtime(calendar:gregorian_seconds_to_datetime(Seconds + ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970)).
-
-time_utc_to_epochs({_, _} = Datetime) ->
- calendar:datetime_to_gregorian_seconds(Datetime) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970;
-time_utc_to_epochs(undefined) ->
- time_utc_to_epochs(erlang:universaltime()).
-
-
-time_local_to_epochs({_, _} = Datetime) ->
- calendar:datetime_to_gregorian_seconds(erlang:localtime_to_universaltime(Datetime)) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970;
-time_local_to_epochs(undefined) ->
- time_utc_to_epochs(erlang:universaltime()).
-
+%file_info_time(epoch, {ok, FI} = R) -> R;
+%file_info_time(local, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
+% {ok, FI#file_info{
+% atime = time_epochs_to_local(Atime),
+% ctime = time_epochs_to_local(Ctime),
+% mtime = time_epochs_to_local(Mtime)
+% }
+% };
+%file_info_time(utc, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
+% {ok, FI#file_info{
+% atime = time_epochs_to_utc(Atime),
+% ctime = time_epochs_to_utc(Ctime),
+% mtime = time_epochs_to_utc(Mtime)
+% }
+% };
+%file_info_time(_, Error) -> Error.
+%
+%%% from_epochs
+%file_info_epochs(epoch, FI) -> FI;
+%file_info_epochs(local, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI) ->
+% FI#file_info{
+% atime = time_local_to_epochs(Atime),
+% ctime = time_local_to_epochs(Ctime),
+% mtime = time_local_to_epochs(Mtime)
+% };
+%file_info_epochs(utc, {ok, #file_info{ atime = Atime, ctime = Ctime, mtime = Mtime } = FI}) ->
+% FI#file_info{
+% atime = time_utc_to_epochs(Atime),
+% ctime = time_utc_to_epochs(Ctime),
+% mtime = time_utc_to_epochs(Mtime)
+% }.
+%
+%
+%-define(DAYS_FROM_0_TO_1970, 719528).
+%-define(SECONDS_PER_DAY, 86400).
+%
+%time_epochs_to_utc(Seconds) when is_integer(Seconds) ->
+% calendar:gregorian_seconds_to_datetime(Seconds + ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970).
+%
+%time_epochs_to_local(Seconds) when is_integer(Seconds) ->
+% erlang:universaltime_to_localtime(calendar:gregorian_seconds_to_datetime(Seconds + ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970)).
+%
+%time_utc_to_epochs({_, _} = Datetime) ->
+% calendar:datetime_to_gregorian_seconds(Datetime) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970;
+%time_utc_to_epochs(undefined) ->
+% time_utc_to_epochs(erlang:universaltime()).
+%
+%
+%time_local_to_epochs({_, _} = Datetime) ->
+% calendar:datetime_to_gregorian_seconds(erlang:localtime_to_universaltime(Datetime)) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970;
+%time_local_to_epochs(undefined) ->
+% time_utc_to_epochs(erlang:universaltime()).
+%
%% file_name(FileName)
%% Generates a flat file name from a deep list of atoms and
diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl
index 64c61ba3ac..81f9efcf39 100644
--- a/lib/kernel/src/file_server.erl
+++ b/lib/kernel/src/file_server.erl
@@ -147,15 +147,24 @@ handle_call({get_cwd, Name}, _From, Handle) ->
handle_call({read_file_info, Name}, _From, Handle) ->
{reply, ?PRIM_FILE:read_file_info(Handle, Name), Handle};
+handle_call({read_file_info, Name, Opts}, _From, Handle) ->
+ {reply, ?PRIM_FILE:read_file_info(Handle, Name, Opts), Handle};
+
handle_call({altname, Name}, _From, Handle) ->
{reply, ?PRIM_FILE:altname(Handle, Name), Handle};
handle_call({write_file_info, Name, Info}, _From, Handle) ->
{reply, ?PRIM_FILE:write_file_info(Handle, Name, Info), Handle};
+handle_call({write_file_info, Name, Info, Opts}, _From, Handle) ->
+ {reply, ?PRIM_FILE:write_file_info(Handle, Name, Info, Opts), Handle};
+
handle_call({read_link_info, Name}, _From, Handle) ->
{reply, ?PRIM_FILE:read_link_info(Handle, Name), Handle};
+handle_call({read_link_info, Name, Opts}, _From, Handle) ->
+ {reply, ?PRIM_FILE:read_link_info(Handle, Name, Opts), Handle};
+
handle_call({read_link, Name}, _From, Handle) ->
{reply, ?PRIM_FILE:read_link(Handle, Name), Handle};