github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/sysfs/stat_bsd.go (about) 1 //go:build (amd64 || arm64) && (darwin || freebsd) 2 3 package sysfs 4 5 import ( 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 17 const dirNlinkIncludesDot = true 18 19 func 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 27 func 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 35 func statFile(f fs.File) (sys.Stat_t, experimentalsys.Errno) { 36 return defaultStatFile(f) 37 }