Removes AccessMode from platform.File (#1472)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2023-05-16 11:32:50 +08:00
committed by GitHub
parent 1c2ca99834
commit 11b346ed75
11 changed files with 39 additions and 96 deletions

View File

@@ -288,13 +288,14 @@ func syscallWrite(mod api.Module, fd int32, offset interface{}, buf []byte) (n i
fsc := mod.(*wasm.ModuleInstance).Sys.FS()
if f, ok := fsc.LookupFile(fd); !ok {
errno = syscall.EBADF
} else if f.File.AccessMode() == syscall.O_RDONLY {
errno = syscall.EBADF
} else if offset != nil {
n, errno = f.File.Pwrite(buf, toInt64(offset))
} else {
n, errno = f.File.Write(buf)
}
if errno == syscall.ENOSYS {
errno = syscall.EBADF // e.g. unimplemented for write
}
return
}