Source File
dir_darwin.go
Belonging Package
os
package os
import (
)
type dirInfo struct {
dir uintptr // Pointer to DIR structure from dirent.h
}
func ( *dirInfo) () {
if .dir == 0 {
return
}
closedir(.dir)
.dir = 0
}
func ( *File) ( int, readdirMode) ( []string, []DirEntry, []FileInfo, error) {
if .dirinfo == nil {
, , := .pfd.OpenDir()
if != nil {
return nil, nil, nil, &PathError{Op: , Path: .name, Err: }
}
.dirinfo = &dirInfo{
dir: ,
}
}
:= .dirinfo
:=
if <= 0 {
= 100
= -1
}
var syscall.Dirent
var *syscall.Dirent
for len()+len()+len() < || == -1 {
if := readdir_r(.dir, &, &); != 0 {
if == syscall.EINTR {
continue
}
return , , , &PathError{Op: "readdir", Path: .name, Err: }
}
if == nil { // EOF
break
}
if .Ino == 0 {
continue
}
:= (*[len(syscall.Dirent{}.Name)]byte)(unsafe.Pointer(&.Name))[:]
for , := range {
if == 0 {
= [:]
break
}
if string() == "." || string() == ".." {
continue
}
if == readdirName {
= append(, string())
} else if == readdirDirEntry {
, := newUnixDirent(.name, string(), dtToType(.Type))
continue
}
if != nil {
return nil, nil, ,
}
= append(, )
}
runtime.KeepAlive()
}
if > 0 && len()+len()+len() == 0 {
return nil, nil, nil, io.EOF
}
return , , , nil
}
func ( uint8) FileMode {
switch {
case syscall.DT_BLK:
return ModeDevice
case syscall.DT_CHR:
return ModeDevice | ModeCharDevice
case syscall.DT_DIR:
return ModeDir
case syscall.DT_FIFO:
return ModeNamedPipe
case syscall.DT_LNK:
return ModeSymlink
case syscall.DT_REG:
return 0
case syscall.DT_SOCK:
return ModeSocket
}
return ^FileMode(0)
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |