1//go:build (amd64 || arm64) && (darwin || freebsd)
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// dirNlinkIncludesDot is true because even though os.File filters out dot
14// entries, the underlying syscall.Stat includes them.
15//
16// Note: this is only used in tests
17const dirNlinkIncludesDot = true
18
19func lstat(path string) (sys.Stat_t, experimentalsys.Errno) {
20 if info, err := os.Lstat(path); err != nil {
21 return sys.Stat_t{}, experimentalsys.UnwrapOSError(err)
22 } else {
23 return sys.NewStat_t(info), 0
24 }
25}
26
27func stat(path string) (sys.Stat_t, experimentalsys.Errno) {
28 if info, err := os.Stat(path); err != nil {
29 return sys.Stat_t{}, experimentalsys.UnwrapOSError(err)
30 } else {
31 return sys.NewStat_t(info), 0
32 }
33}
34
35func statFile(f fs.File) (sys.Stat_t, experimentalsys.Errno) {
36 return defaultStatFile(f)
37}