| author | |
| committer | |
| log | 78b7a446f0dd67f1d4dcb730065558bd93399957 |
| tree | b2bcbb5e81773e01fb775135977f21a4556c8a59 |
| parent | 71d16106ad76bb31bc4e17dc37f8d8b5498a12dd |
3 files changed, 23 insertions(+), 13 deletions(-)
lib/std/c.zig+4-4| ... | ... | @@ -9388,11 +9388,11 @@ pub extern "c" fn malloc(usize) ?*anyopaque; |
| 9388 | 9388 | pub extern "c" fn realloc(?*anyopaque, usize) ?*anyopaque; |
| 9389 | 9389 | pub extern "c" fn free(?*anyopaque) void; |
| 9390 | 9390 | |
| 9391 | pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int; | |
| 9392 | pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int; | |
| 9391 | pub extern "c" fn futimes(fd: fd_t, times: ?*[2]timeval) c_int; | |
| 9392 | pub extern "c" fn utimes(path: [*:0]const u8, times: ?*[2]timeval) c_int; | |
| 9393 | 9393 | |
| 9394 | pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int; | |
| 9395 | pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int; | |
| 9394 | pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: ?*[2]timespec, flags: u32) c_int; | |
| 9395 | pub extern "c" fn futimens(fd: fd_t, times: ?*const [2]timespec) c_int; | |
| 9396 | 9396 | |
| 9397 | 9397 | pub extern "c" fn pthread_create( |
| 9398 | 9398 | noalias newthread: *pthread_t, |
lib/std/os/linux.zig+2-2| ... | ... | @@ -608,11 +608,11 @@ pub inline fn vfork() usize { |
| 608 | 608 | return @call(.always_inline, syscall0, .{.vfork}); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | pub fn futimens(fd: i32, times: *const [2]timespec) usize { | |
| 611 | pub fn futimens(fd: i32, times: ?*const [2]timespec) usize { | |
| 612 | 612 | return utimensat(fd, null, times, 0); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, flags: u32) usize { | |
| 615 | pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: ?*const [2]timespec, flags: u32) usize { | |
| 616 | 616 | return syscall4(.utimensat, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), @intFromPtr(times), flags); |
| 617 | 617 | } |
| 618 | 618 |
lib/std/posix.zig+17-7| ... | ... | @@ -5767,17 +5767,27 @@ pub const FutimensError = error{ |
| 5767 | 5767 | ReadOnlyFileSystem, |
| 5768 | 5768 | } || UnexpectedError; |
| 5769 | 5769 | |
| 5770 | pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { | |
| 5770 | pub fn futimens(fd: fd_t, times: ?*const [2]timespec) FutimensError!void { | |
| 5771 | 5771 | if (native_os == .wasi and !builtin.link_libc) { |
| 5772 | 5772 | // TODO WASI encodes `wasi.fstflags` to signify magic values |
| 5773 | 5773 | // similar to UTIME_NOW and UTIME_OMIT. Currently, we ignore |
| 5774 | 5774 | // this here, but we should really handle it somehow. |
| 5775 | const atim = times[0].toTimestamp(); | |
| 5776 | const mtim = times[1].toTimestamp(); | |
| 5777 | switch (wasi.fd_filestat_set_times(fd, atim, mtim, .{ | |
| 5778 | .ATIM = true, | |
| 5779 | .MTIM = true, | |
| 5780 | })) { | |
| 5775 | const error_code = blk: { | |
| 5776 | if (times) |times_arr| { | |
| 5777 | const atim = times_arr[0].toTimestamp(); | |
| 5778 | const mtim = times_arr[1].toTimestamp(); | |
| 5779 | break :blk wasi.fd_filestat_set_times(fd, atim, mtim, .{ | |
| 5780 | .ATIM = true, | |
| 5781 | .MTIM = true, | |
| 5782 | }); | |
| 5783 | } | |
| 5784 | ||
| 5785 | break :blk wasi.fd_filestat_set_times(fd, 0, 0, .{ | |
| 5786 | .ATIM_NOW = true, | |
| 5787 | .MTIM_NOW = true, | |
| 5788 | }); | |
| 5789 | }; | |
| 5790 | switch (error_code) { | |
| 5781 | 5791 | .SUCCESS => return, |
| 5782 | 5792 | .ACCES => return error.AccessDenied, |
| 5783 | 5793 | .PERM => return error.PermissionDenied, |