2014-02-21 04:12:25 -05:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2015-12-13 11:00:39 -05:00
|
|
|
// LUtimesNano is used to change access and modification time of the specified path.
|
2015-07-28 12:13:12 -04:00
|
|
|
// It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm.
|
2014-02-21 04:12:25 -05:00
|
|
|
func LUtimesNano(path string, ts []syscall.Timespec) error {
|
|
|
|
// These are not currently available in syscall
|
2015-07-28 12:13:12 -04:00
|
|
|
atFdCwd := -100
|
|
|
|
atSymLinkNoFollow := 0x100
|
2014-02-21 04:12:25 -05:00
|
|
|
|
|
|
|
var _path *byte
|
|
|
|
_path, err := syscall.BytePtrFromString(path)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-07-28 12:13:12 -04:00
|
|
|
if _, _, err := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(atSymLinkNoFollow), 0, 0); err != 0 && err != syscall.ENOSYS {
|
2014-02-21 04:12:25 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|