Big merge of changes to gofrontend repo that were postponed due to the
[official-gcc.git] / libgo / go / syscall / libcall_posix_utimesnano.go
blob372b0d75eb260ff971d4f1f01b9de1c679a856e7
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 // +build aix darwin dragonfly freebsd openbsd netbsd solaris
7 // General POSIX version of UtimesNano.
9 package syscall
11 import "unsafe"
13 func UtimesNano(path string, ts []Timespec) error {
14 // TODO: The BSDs can do utimensat with SYS_UTIMENSAT but it
15 // isn't supported by darwin so this uses utimes instead
16 if len(ts) != 2 {
17 return EINVAL
19 // Not as efficient as it could be because Timespec and
20 // Timeval have different types in the different OSes
21 tv := [2]Timeval{
22 NsecToTimeval(TimespecToNsec(ts[0])),
23 NsecToTimeval(TimespecToNsec(ts[1])),
25 return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))