mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
os: implement readdir for darwin and linux
readdir is disabled on linux for 386 and arm until syscall.seek is implemented there. windows is hard, so leaving that for later. File src/os/dir_other_go115.go can be deleted when we drop support for go 1.15. Also adds TestReadNonDir, which was helpful while debugging.
This commit is contained in:
@@ -19,6 +19,14 @@ func Close(fd int) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func Dup(fd int) (fd2 int, err error) {
|
||||
fd2 = int(libc_dup(int32(fd)))
|
||||
if fd2 < 0 {
|
||||
err = getErrno()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Write(fd int, p []byte) (n int, err error) {
|
||||
buf, count := splitSlice(p)
|
||||
n = libc_write(int32(fd), buf, uint(count))
|
||||
@@ -297,6 +305,10 @@ func libc_open(pathname *byte, flags int32, mode uint32) int32
|
||||
//export close
|
||||
func libc_close(fd int32) int32
|
||||
|
||||
// int dup(int fd)
|
||||
//export dup
|
||||
func libc_dup(fd int32) int32
|
||||
|
||||
// void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
|
||||
//export mmap
|
||||
func libc_mmap(addr unsafe.Pointer, length uintptr, prot, flags, fd int32, offset uintptr) unsafe.Pointer
|
||||
|
||||
Reference in New Issue
Block a user