aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2011-11-30 18:41:15 +0100
committerBjörn-Egil Dahlberg <[email protected]>2011-12-02 15:41:14 +0100
commit2a1f035f777b5caef0c47dfd863675ef51296c3d (patch)
tree0e9c76390727002f5e9add8ca4fbf46b4a4fc98f /erts/preloaded
parent4ee95bc5c0113da005feeded022876383879d55c (diff)
downloadotp-2a1f035f777b5caef0c47dfd863675ef51296c3d.tar.gz
otp-2a1f035f777b5caef0c47dfd863675ef51296c3d.tar.bz2
otp-2a1f035f777b5caef0c47dfd863675ef51296c3d.zip
Fix validate structure in file_info
Diffstat (limited to 'erts/preloaded')
-rw-r--r--erts/preloaded/src/prim_file.erl24
1 files changed, 13 insertions, 11 deletions
diff --git a/erts/preloaded/src/prim_file.erl b/erts/preloaded/src/prim_file.erl
index b781dffba5..a301abb667 100644
--- a/erts/preloaded/src/prim_file.erl
+++ b/erts/preloaded/src/prim_file.erl
@@ -773,8 +773,7 @@ write_file_info(File, Info, Opts) ->
write_file_info(Port, File, Info, Opts) when is_port(Port) ->
write_file_info_int(Port, File, Info, plgv(time, Opts, local)).
-write_file_info_int(Port,
- File,
+write_file_info_int(Port, File,
#file_info{mode=Mode,
uid=Uid,
gid=Gid,
@@ -783,16 +782,12 @@ write_file_info_int(Port,
ctime=Ctime},
TimeType) ->
- %% FIXME: wtf
- %% sätt atime beroende på timetype, om ej satt
- %% sätt mtime som atime, om ej satt
+ % Atime and/or Mtime might be undefined
+ % - use localtime() for atime, if atime is undefined
+ % - use atime as mtime if mtime is undefined
- {Atime, Mtime} = case {Atime0, Mtime0} of
- {undefined, Mtime0} -> {erlang:localtime(), Mtime0};
- {Atime0, undefined} -> {Atime0, Atime0};
- {undefined, undefined} -> {erlang:localtime(), erlang:localtime()};
- Complete -> Complete
- end,
+ Atime = file_info_validate_atime(Atime0, TimeType),
+ Mtime = file_info_validate_mtime(Mtime0, Atime),
drv_command(Port, [?FILE_WRITE_INFO,
int_to_int32bytes(Mode),
@@ -804,6 +799,13 @@ write_file_info_int(Port,
pathname(File)]).
+file_info_validate_atime(Atime, _) when Atime =/= undefined -> Atime;
+file_info_validate_atime(undefined, local) -> erlang:localtime();
+file_info_validate_atime(undefined, utc) -> erlang:universaltime();
+file_info_validate_atime(undefined, epoch) -> datetime_to_epoch(erlang:universaltime()).
+
+file_info_validate_mtime(undefined, Atime) -> Atime;
+file_info_validate_mtime(Mtime, _) -> Mtime.
%% make_link/{2,3}