mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 16:33:40 +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:
+17
-8
@@ -33,20 +33,29 @@ func rename(oldname, newname string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type file struct {
|
||||
handle FileHandle
|
||||
name string
|
||||
}
|
||||
|
||||
func NewFile(fd FileHandle, name string) *File {
|
||||
return &File{&file{fd, name}}
|
||||
}
|
||||
|
||||
func Pipe() (r *File, w *File, err error) {
|
||||
var p [2]syscall.Handle
|
||||
e := handleSyscallError(syscall.Pipe(p[:]))
|
||||
if e != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
r = &File{
|
||||
handle: unixFileHandle(p[0]),
|
||||
name: "|0",
|
||||
}
|
||||
w = &File{
|
||||
handle: unixFileHandle(p[1]),
|
||||
name: "|1",
|
||||
}
|
||||
r = NewFile(
|
||||
unixFileHandle(p[0]),
|
||||
"|0",
|
||||
)
|
||||
w = NewFile(
|
||||
unixFileHandle(p[1]),
|
||||
"|1",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user