Skip to content

Commit

Permalink
zip: Do not fallback to dostime for ctime
Browse files Browse the repository at this point in the history
On Windows if you write ctime it will change it, while on unix it does not.
So we don't update ctime unless it is part of the archive which is never is.
  • Loading branch information
garazdawi committed Jun 26, 2024
1 parent 5c49b34 commit 4d42737
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/stdlib/src/zip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2424,14 +2424,13 @@ file_header_atime_to_datetime(FH) ->
calendar:system_time_to_local_time(Atime, second)
end.

%% If we have ctime we use that, otherwise use dos time
%% Normally ctime will not be set, but if it is we use that. If it is not set
%% we return undefined so that when we later do write_file_info ctime will remain
%% the time that the file was created when extracted from the archive.
file_header_ctime_to_datetime(FH) ->
#cd_file_header.ctime = #local_file_header.ctime,
case element(#cd_file_header.ctime, FH) of
undefined ->
dos_date_time_to_datetime(
element(#cd_file_header.last_mod_date, FH),
element(#cd_file_header.last_mod_time, FH));
undefined -> undefined;
Ctime ->
calendar:system_time_to_local_time(Ctime, second)
end.
Expand Down

0 comments on commit 4d42737

Please sign in to comment.