This forces all syscall functions, notably filesystem, to return numeric codes as opposed to mapping in two different areas. The result of this change is better consolidation in call sites of `sysfs.FS`, while further refactoring is needed to address consolidation of file errors. Signed-off-by: Adrian Cole <adrian@tetrate.io>
20 lines
390 B
Go
20 lines
390 B
Go
package platform
|
|
|
|
import (
|
|
"io/fs"
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
// See the comments on the same constants in open_file_windows.go
|
|
const (
|
|
O_DIRECTORY = 1 << 29
|
|
O_NOFOLLOW = 1 << 30
|
|
)
|
|
|
|
func OpenFile(path string, flag int, perm fs.FileMode) (File, syscall.Errno) {
|
|
flag &= ^(O_DIRECTORY | O_NOFOLLOW) // erase placeholders
|
|
f, err := os.OpenFile(path, flag, perm)
|
|
return f, UnwrapOSError(err)
|
|
}
|