aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/file.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-11-26 11:11:01 +0100
committerLukas Larsson <[email protected]>2014-11-26 11:11:01 +0100
commit4192870b70ec65ddb13ae876f32fb211ec8ff29d (patch)
tree05fe21ca6c6d6d3c83c95a462c46d281fe524656 /lib/kernel/src/file.erl
parent6d6048d997e60fcfa6a0e07d010cbf605738ad40 (diff)
parent33ef9019afb4cd268d5c9e54e63e428630686d63 (diff)
downloadotp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.tar.gz
otp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.tar.bz2
otp-4192870b70ec65ddb13ae876f32fb211ec8ff29d.zip
Merge branch 'maint'
* maint: kernel: Do not check unsync:ed file size Introduce new option 'raw' in file_info functions
Diffstat (limited to 'lib/kernel/src/file.erl')
-rw-r--r--lib/kernel/src/file.erl62
1 files changed, 42 insertions, 20 deletions
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 7b2750846e..b6b153ae56 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -114,7 +114,7 @@
-type sendfile_option() :: {chunk_size, non_neg_integer()}
| {use_threads, boolean()}.
-type file_info_option() :: {'time', 'local'} | {'time', 'universal'}
- | {'time', 'posix'}.
+ | {'time', 'posix'} | raw.
%%% BIFs
-export([native_name_encoding/0]).
@@ -242,7 +242,19 @@ read_file_info(Name) ->
Reason :: posix() | badarg.
read_file_info(Name, Opts) when is_list(Opts) ->
- check_and_call(read_file_info, [file_name(Name), Opts]).
+ Args = [file_name(Name), Opts],
+ case check_args(Args) of
+ ok ->
+ case lists:member(raw, Opts) of
+ true ->
+ [FileName|_] = Args,
+ ?PRIM_FILE:read_file_info(FileName, Opts);
+ false ->
+ call(read_file_info, Args)
+ end;
+ Error ->
+ Error
+ end.
-spec altname(Name :: name_all()) -> any().
@@ -264,7 +276,19 @@ read_link_info(Name) ->
Reason :: posix() | badarg.
read_link_info(Name, Opts) when is_list(Opts) ->
- check_and_call(read_link_info, [file_name(Name),Opts]).
+ Args = [file_name(Name), Opts],
+ case check_args(Args) of
+ ok ->
+ case lists:member(raw, Opts) of
+ true ->
+ [FileName|_] = Args,
+ ?PRIM_FILE:read_link_info(FileName, Opts);
+ false ->
+ call(read_link_info, Args)
+ end;
+ Error ->
+ Error
+ end.
-spec read_link(Name) -> {ok, Filename} | {error, Reason} when
@@ -298,7 +322,19 @@ write_file_info(Name, Info = #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), Info, Opts]).
+ Args = [file_name(Name), Info, Opts],
+ case check_args(Args) of
+ ok ->
+ case lists:member(raw, Opts) of
+ true ->
+ [FileName|_] = Args,
+ ?PRIM_FILE:write_file_info(FileName, Info, Opts);
+ false ->
+ call(write_file_info, Args)
+ end;
+ Error ->
+ Error
+ end.
-spec list_dir(Dir) -> {ok, Filenames} | {error, Reason} when
Dir :: name_all(),
@@ -384,26 +420,12 @@ write_file(Name, Bin, ModeList) when is_list(ModeList) ->
%% Obsolete, undocumented, local node only, don't use!.
%% XXX to be removed.
raw_read_file_info(Name) ->
- Args = [file_name(Name)],
- case check_args(Args) of
- ok ->
- [FileName] = Args,
- ?PRIM_FILE:read_file_info(FileName);
- Error ->
- Error
- end.
+ read_file_info(Name, [raw]).
%% Obsolete, undocumented, local node only, don't use!.
%% XXX to be removed.
raw_write_file_info(Name, #file_info{} = Info) ->
- Args = [file_name(Name)],
- case check_args(Args) of
- ok ->
- [FileName] = Args,
- ?PRIM_FILE:write_file_info(FileName, Info);
- Error ->
- Error
- end.
+ write_file_info(Name, Info, [raw]).
%%%-----------------------------------------------------------------
%%% File io server functions.