]>
Commit | Line | Data |
---|---|---|
320054e8 DG |
1 | // Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/ |
2 | // | |
3 | // SPDX-License-Identifier: BSD-2-Clause | |
4 | ||
320054e8 DG |
5 | #include <sys/stat.h> |
6 | ||
446cb3f1 | 7 | #include <wasi/api.h> |
320054e8 DG |
8 | #include <errno.h> |
9 | #include <fcntl.h> | |
10 | #include <string.h> | |
11 | ||
12 | #include "stat_impl.h" | |
13 | ||
f2e779e5 DG |
14 | int __wasilibc_nocwd_utimensat(int fd, const char *path, const struct timespec times[2], |
15 | int flag) { | |
320054e8 | 16 | // Convert timestamps and extract NOW/OMIT flags. |
320054e8 DG |
17 | __wasi_timestamp_t st_atim; |
18 | __wasi_timestamp_t st_mtim; | |
19 | __wasi_fstflags_t flags; | |
20 | if (!utimens_get_timestamps(times, &st_atim, &st_mtim, &flags)) { | |
320054e8 DG |
21 | return -1; |
22 | } | |
23 | ||
24 | // Create lookup properties. | |
320054e8 | 25 | __wasi_lookupflags_t lookup_flags = 0; |
320054e8 | 26 | if ((flag & AT_SYMLINK_NOFOLLOW) == 0) |
446cb3f1 | 27 | lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW; |
320054e8 DG |
28 | |
29 | // Perform system call. | |
30 | __wasi_errno_t error = | |
2b7e73ae | 31 | __wasi_path_filestat_set_times(fd, lookup_flags, path, st_atim, st_mtim, flags); |
320054e8 | 32 | if (error != 0) { |
320054e8 DG |
33 | return -1; |
34 | } | |
35 | return 0; | |
36 | } |