github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/sysfs/stat_unsupported.go (about)

     1  //go:build (!((amd64 || arm64 || riscv64) && linux) && !((amd64 || arm64) && (darwin || freebsd)) && !((amd64 || arm64) && windows)) || js
     2  
     3  package sysfs
     4  
     5  import (
     6  	"io/fs"
     7  	"os"
     8  
     9  	experimentalsys "github.com/wasilibs/wazerox/experimental/sys"
    10  	"github.com/wasilibs/wazerox/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
    20  const dirNlinkIncludesDot = false
    21  
    22  func 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  
    30  func 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  
    38  func statFile(f fs.File) (sys.Stat_t, experimentalsys.Errno) {
    39  	return defaultStatFile(f)
    40  }