WASI & darwin: support basic file io based on libc

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2021-03-18 12:53:32 +09:00
committed by Ron Evans
parent 6d3c11627c
commit 1406453350
16 changed files with 390 additions and 84 deletions
+17
View File
@@ -1,3 +1,5 @@
// +build darwin
package syscall
// This file defines errno and constants to match the darwin libsystem ABI.
@@ -22,10 +24,25 @@ func getErrno() Errno {
return Errno(uintptr(*errptr))
}
func (e Errno) Is(target error) bool {
switch target.Error() {
case "permission denied":
return e == EACCES || e == EPERM
case "file already exists":
return e == EEXIST
case "file does not exist":
return e == ENOENT
}
return false
}
const (
EPERM Errno = 0x1
ENOENT Errno = 0x2
EACCES Errno = 0xd
EEXIST Errno = 0x11
EINTR Errno = 0x4
ENOTDIR Errno = 0x14
EMFILE Errno = 0x18
EAGAIN Errno = 0x23
ETIMEDOUT Errno = 0x3c