1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use crate::fs::{open, OpenOptions, SystemTimeSpec};
use rustix::io::Errno;
use std::path::Path;
use std::{fs, io};
pub(crate) fn set_times_impl(
start: &fs::File,
path: &Path,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> io::Result<()> {
match open(start, path, OpenOptions::new().write(true)) {
Ok(file) => {
return fs_set_times::SetTimes::set_times(
&file,
atime.map(SystemTimeSpec::into_std),
mtime.map(SystemTimeSpec::into_std),
)
}
Err(err) => match Errno::from_io_error(&err) {
Some(Errno::ACCESS) | Some(Errno::ISDIR) => (),
_ => return Err(err),
},
}
match open(start, path, OpenOptions::new().read(true)) {
Ok(file) => {
return fs_set_times::SetTimes::set_times(
&file,
atime.map(SystemTimeSpec::into_std),
mtime.map(SystemTimeSpec::into_std),
)
}
Err(err) => match Errno::from_io_error(&err) {
Some(Errno::ACCESS) => (),
_ => return Err(err),
},
}
Err(Errno::NOTSUP.into())
}