...

Source file src/internal/poll/fd_opendir_darwin.go

     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	package poll
     6	
     7	import (
     8		"syscall"
     9		_ "unsafe" // for go:linkname
    10	)
    11	
    12	// OpenDir returns a pointer to a DIR structure suitable for
    13	// ReadDir. In case of an error, the name of the failed
    14	// syscall is returned along with a syscall.Errno.
    15	func (fd *FD) OpenDir() (uintptr, string, error) {
    16		// fdopendir(3) takes control of the file descriptor,
    17		// so use a dup.
    18		fd2, call, err := fd.Dup()
    19		if err != nil {
    20			return 0, call, err
    21		}
    22		dir, err := fdopendir(fd2)
    23		if err != nil {
    24			syscall.Close(fd2)
    25			return 0, "fdopendir", err
    26		}
    27		return dir, "", nil
    28	}
    29	
    30	// Implemented in syscall/syscall_darwin.go.
    31	//go:linkname fdopendir syscall.fdopendir
    32	func fdopendir(fd int) (dir uintptr, err error)
    33	

View as plain text