1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // GNU/Linux version of UtimesNano.
11 //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
12 //utimensat(dirfd _C_int, path *byte, times *[2]Timespec, flags _C_int) _C_int
13 func UtimesNano(path
string, ts
[]Timespec
) (err error
) {
17 err
= utimensat(_AT_FDCWD
, path
, (*[2]Timespec
)(unsafe
.Pointer(&ts
[0])), 0)
21 // If the utimensat syscall isn't available (utimensat was added to Linux
22 // in 2.6.22, Released, 8 July 2007) then fall back to utimes
24 for i
:= 0; i
< 2; i
++ {
25 tv
[i
].Sec
= Timeval_sec_t(ts
[i
].Sec
)
26 tv
[i
].Usec
= Timeval_usec_t(ts
[i
].Nsec
/ 1000)
28 return utimes(path
, (*[2]Timeval
)(unsafe
.Pointer(&tv
[0])))