1//go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js
2
3package sysfs
4
5import (
6 "io/fs"
7 "os"
8
9 experimentalsys "github.com/tetratelabs/wazero/experimental/sys"
10 "github.com/tetratelabs/wazero/sys"
11)
12
13// Note: go:build constraints must be the same as /sys.stat_unsupported.go for
14// the same reasons.
15
16// dirNlinkIncludesDot might be true for some operating systems, which can have
17// new stat_XX.go files as necessary.
18//
19// Note: this is only used in tests
20const dirNlinkIncludesDot = false
21
22func lstat(path string) (sys.Stat_t, experimentalsys.Errno) {
23 if info, err := os.Lstat(path); err != nil {
24 return sys.Stat_t{}, experimentalsys.UnwrapOSError(err)
25 } else {
26 return sys.NewStat_t(info), 0
27 }
28}
29
30func stat(path string) (sys.Stat_t, experimentalsys.Errno) {
31 if info, err := os.Stat(path); err != nil {
32 return sys.Stat_t{}, experimentalsys.UnwrapOSError(err)
33 } else {
34 return sys.NewStat_t(info), 0
35 }
36}
37
38func statFile(f fs.File) (sys.Stat_t, experimentalsys.Errno) {
39 return defaultStatFile(f)
40}