forked from tetratelabs/wazero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
futimens.go
37 lines (31 loc) · 888 Bytes
/
futimens.go
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
//go:build linux || darwin
package sysfs
import (
"syscall"
"unsafe"
"github.com/bananabytelabs/wazero/experimental/sys"
)
func timesToPtr(times *[2]syscall.Timespec) unsafe.Pointer { //nolint:unused
if times != nil {
return unsafe.Pointer(×[0])
}
return unsafe.Pointer(nil)
}
func timesToTimespecs(atim int64, mtim int64) (times *[2]syscall.Timespec) {
// When both inputs are omitted, there is nothing to change.
if atim == sys.UTIME_OMIT && mtim == sys.UTIME_OMIT {
return
}
times = &[2]syscall.Timespec{}
if atim == sys.UTIME_OMIT {
times[0] = syscall.Timespec{Nsec: _UTIME_OMIT}
times[1] = syscall.NsecToTimespec(mtim)
} else if mtim == sys.UTIME_OMIT {
times[0] = syscall.NsecToTimespec(atim)
times[1] = syscall.Timespec{Nsec: _UTIME_OMIT}
} else {
times[0] = syscall.NsecToTimespec(atim)
times[1] = syscall.NsecToTimespec(mtim)
}
return
}