github.com/icodeface/tls@v0.0.0-20230910023335-34df9250cd12/internal/poll/fd_opendir_ios.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build darwin 6 // +build arm arm64 7 8 package poll 9 10 import ( 11 "syscall" 12 _ "unsafe" // for go:linkname 13 ) 14 15 // OpenDir returns a pointer to a DIR structure suitable for 16 // ReadDir. In case of an error, the name of the failed 17 // syscall is returned along with a syscall.Errno. 18 func (fd *FD) OpenDir() (uintptr, string, error) { 19 // fdopendir(3) takes control of the file descriptor, 20 // so use a dup. 21 fd2, call, err := fd.Dup() 22 if err != nil { 23 return 0, call, err 24 } 25 dir, err := fdopendir(fd2) 26 if err != nil { 27 syscall.Close(fd2) 28 return 0, "fdopendir", err 29 } 30 return dir, "", nil 31 } 32 33 // Implemented in syscall/syscall_darwin.go. 34 //go:linkname fdopendir syscall.fdopendir 35 func fdopendir(fd int) (dir uintptr, err error)