package os
import (
)
type dirInfo struct {
dir uintptr
}
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 {
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))
if IsNotExist() {
continue
}
if != nil {
return nil, , nil,
}
= append(, )
} else {
, := lstat(.name + "/" + string())
if IsNotExist() {
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)
}
func ( uintptr) ( error)
func ( uintptr, *syscall.Dirent, **syscall.Dirent) ( syscall.Errno)