open_file_notwindows.go

 1//go:build !windows && !tinygo
 2
 3package sysfs
 4
 5import (
 6	"io/fs"
 7	"os"
 8
 9	"github.com/tetratelabs/wazero/experimental/sys"
10)
11
12// openFile is like os.OpenFile except it accepts a sys.Oflag and returns
13// sys.Errno. A zero sys.Errno is success.
14func openFile(path string, oflag sys.Oflag, perm fs.FileMode) (*os.File, sys.Errno) {
15	f, err := os.OpenFile(path, toOsOpenFlag(oflag), perm)
16	// Note: This does not return a sys.File because sys.FS that returns
17	// one may want to hide the real OS path. For example, this is needed for
18	// pre-opens.
19	return f, sys.UnwrapOSError(err)
20}