...
1 package sysfs
2
3 import (
4 "syscall"
5
6 "github.com/tetratelabs/wazero/experimental/sys"
7 "github.com/tetratelabs/wazero/internal/platform"
8 )
9
10 func utimens(path string, atim, mtim int64) sys.Errno {
11 return chtimes(path, atim, mtim)
12 }
13
14 func futimens(fd uintptr, atim, mtim int64) error {
15
16
17 if !platform.IsAtLeastGo120 {
18 return sys.ENOSYS
19 }
20
21
22
23
24 a, w := timespecToFiletime(atim, mtim)
25
26 if a == nil && w == nil {
27 return nil
28 }
29
30
31 h := syscall.Handle(fd)
32
33
34 return syscall.SetFileTime(h, nil, a, w)
35 }
36
37 func timespecToFiletime(atim, mtim int64) (a, w *syscall.Filetime) {
38 a = timespecToFileTime(atim)
39 w = timespecToFileTime(mtim)
40 return
41 }
42
43 func timespecToFileTime(tim int64) *syscall.Filetime {
44 if tim == sys.UTIME_OMIT {
45 return nil
46 }
47 ft := syscall.NsecToFiletime(tim)
48 return &ft
49 }
50
View as plain text