| ... | ... | @@ -6046,11 +6046,34 @@ fn fileSetTimestamps( |
| 6046 | 6046 | if (is_windows) { |
| 6047 | 6047 | try current_thread.checkCancel(); |
| 6048 | 6048 | |
| 6049 | | const atime_ft = windows.nanoSecondsToFileTime(options.access_time); |
| 6050 | | const mtime_ft = windows.nanoSecondsToFileTime(options.modify_time); |
| 6049 | var access_time_buffer: windows.FILETIME = undefined; |
| 6050 | var modify_time_buffer: windows.FILETIME = undefined; |
| 6051 | var system_time_buffer: windows.LARGE_INTEGER = undefined; |
| 6052 | |
| 6053 | if (options.access_timestamp == .now or options.modify_timestamp == .now) { |
| 6054 | system_time_buffer = windows.ntdll.RtlGetSystemTimePrecise(); |
| 6055 | } |
| 6056 | |
| 6057 | const access_ptr = switch (options.access_timestamp) { |
| 6058 | .unchanged => null, |
| 6059 | .now => @panic("TODO do SystemTimeToFileTime logic here"), |
| 6060 | .new => |ts| p: { |
| 6061 | access_time_buffer = windows.nanoSecondsToFileTime(ts); |
| 6062 | break :p &access_time_buffer; |
| 6063 | }, |
| 6064 | }; |
| 6065 | |
| 6066 | const modify_ptr = switch (options.modify_timestamp) { |
| 6067 | .unchanged => null, |
| 6068 | .now => @panic("TODO do SystemTimeToFileTime logic here"), |
| 6069 | .new => |ts| p: { |
| 6070 | modify_time_buffer = windows.nanoSecondsToFileTime(ts); |
| 6071 | break :p &modify_time_buffer; |
| 6072 | }, |
| 6073 | }; |
| 6051 | 6074 | |
| 6052 | 6075 | // https://github.com/ziglang/zig/issues/1840 |
| 6053 | | const rc = windows.kernel32.SetFileTime(file.handle, null, &atime_ft, &mtime_ft); |
| 6076 | const rc = windows.kernel32.SetFileTime(file.handle, null, access_ptr, modify_ptr); |
| 6054 | 6077 | if (rc == 0) { |
| 6055 | 6078 | switch (windows.GetLastError()) { |
| 6056 | 6079 | else => |err| return windows.unexpectedError(err), |
| ... | ... | @@ -6060,8 +6083,8 @@ fn fileSetTimestamps( |
| 6060 | 6083 | } |
| 6061 | 6084 | |
| 6062 | 6085 | if (native_os == .wasi and !builtin.link_libc) { |
| 6063 | | const atim = timestampToPosix(options.access_time.nanoseconds).toTimestamp(); |
| 6064 | | const mtim = timestampToPosix(options.modify_time.nanoseconds).toTimestamp(); |
| 6086 | const atim = timestampToPosix(options.access_timestamp.nanoseconds).toTimestamp(); |
| 6087 | const mtim = timestampToPosix(options.modify_timestamp.nanoseconds).toTimestamp(); |
| 6065 | 6088 | try current_thread.beginSyscall(); |
| 6066 | 6089 | while (true) switch (std.os.wasi.fd_filestat_set_times(file.handle, atim, mtim, .{ |
| 6067 | 6090 | .ATIM = true, |