15 if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 {
16 // This is a 64 bit timespec
17 // os.Chtimes limits time to the following
18 maxTime = time.Unix(0, 1<<63-1)
20 // This is a 32 bit timespec
21 maxTime = time.Unix(1<<31-1, 0)
25 // Chtimes changes the access time and modified time of a file at the given path
26 func Chtimes(name string, atime time.Time, mtime time.Time) error {
27 unixMinTime := time.Unix(0, 0)
28 unixMaxTime := maxTime
30 // If the modified time is prior to the Unix Epoch, or after the
31 // end of Unix Time, os.Chtimes has undefined behavior
32 // default to Unix Epoch in this case, just in case
34 if atime.Before(unixMinTime) || atime.After(unixMaxTime) {
38 if mtime.Before(unixMinTime) || mtime.After(unixMaxTime) {
42 if err := os.Chtimes(name, atime, mtime); err != nil {