(
dirfd: BorrowedFd<'_>,
path: &CStr,
times: &Timestamps,
flags: AtFlags,
)
| 886 | target_os = "vita" |
| 887 | )))] |
| 888 | pub(crate) fn utimensat( |
| 889 | dirfd: BorrowedFd<'_>, |
| 890 | path: &CStr, |
| 891 | times: &Timestamps, |
| 892 | flags: AtFlags, |
| 893 | ) -> io::Result<()> { |
| 894 | // Old 32-bit version: libc has `utimensat` but it is not y2038 safe by |
| 895 | // default. But there may be a `__utimensat64` we can use. |
| 896 | #[cfg(all(fix_y2038, not(apple)))] |
| 897 | { |
| 898 | #[cfg(target_env = "gnu")] |
| 899 | if let Some(libc_utimensat) = __utimensat64.get() { |
| 900 | let libc_times: [LibcTimespec; 2] = |
| 901 | [times.last_access.into(), times.last_modification.into()]; |
| 902 | |
| 903 | unsafe { |
| 904 | return ret(libc_utimensat( |
| 905 | borrowed_fd(dirfd), |
| 906 | c_str(path), |
| 907 | libc_times.as_ptr(), |
| 908 | bitflags_bits!(flags), |
| 909 | )); |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | utimensat_old(dirfd, path, times, flags) |
| 914 | } |
| 915 | |
| 916 | // Main version: libc is y2038 safe and has `utimensat`. Or, the platform |
| 917 | // is not y2038 safe and there's nothing practical we can do. |
| 918 | #[cfg(not(any(apple, fix_y2038)))] |
| 919 | unsafe { |
| 920 | use crate::utils::as_ptr; |
| 921 | |
| 922 | ret(c::utimensat( |
| 923 | borrowed_fd(dirfd), |
| 924 | c_str(path), |
| 925 | as_ptr(times).cast(), |
| 926 | bitflags_bits!(flags), |
| 927 | )) |
| 928 | } |
| 929 | |
| 930 | // Apple version: `utimensat` was introduced in macOS 10.13. |
| 931 | #[cfg(apple)] |
| 932 | unsafe { |
| 933 | use crate::utils::as_ptr; |
| 934 | |
| 935 | // ABI details |
| 936 | weak! { |
| 937 | fn utimensat( |
| 938 | c::c_int, |
| 939 | *const ffi::c_char, |
| 940 | *const c::timespec, |
| 941 | c::c_int |
| 942 | ) -> c::c_int |
| 943 | } |
| 944 | extern "C" { |
| 945 | fn setattrlist( |
no test coverage detected