Files
wazero/internal/platform/open_file.go
Crypt Keeper 7721f0ab97 build: makes wazero buildable on solaris and illumos (#1274)
This fixes a build problem on solaris and illumos. This also closes
issue #1106 because we can't make everything build with CGO (e.g. our
examples won't build unless CGO is available).

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-03-23 08:09:21 +09:00

24 lines
567 B
Go

//go:build !windows && !js && !illumos && !solaris
package platform
import (
"io/fs"
"os"
"syscall"
)
// Simple aliases to constants in the syscall package for portability with
// platforms which do not have them (e.g. windows)
const (
O_DIRECTORY = syscall.O_DIRECTORY
O_NOFOLLOW = syscall.O_NOFOLLOW
)
// OpenFile is like os.OpenFile except it returns syscall.Errno. A zero
// syscall.Errno is success.
func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) {
f, err := os.OpenFile(path, flag, perm)
return f, UnwrapOSError(err)
}