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:
Dan Kegel
2022-01-08 12:28:32 -08:00
committed by Ron Evans
parent 3fa7d6cc40
commit 641a7e5cb9
20 changed files with 972 additions and 67 deletions
+17 -8
View File
@@ -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
}