Add bounded concurrent scanner
Single-writer controller with a select loop that offers jobs and accepts results simultaneously, so bounded channels cannot deadlock. statx/fstatat relative to the directory fd on Linux/macOS, portable fallback elsewhere. Hard links counted once, symlink loops detected, virtual filesystems skipped, errors classified and surfaced.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//go:build !linux && !darwin && !freebsd
|
||||
|
||||
package platform
|
||||
|
||||
import "os"
|
||||
|
||||
// ReadDir streams the entries of a directory using the portable os API.
|
||||
// Allocated size, inode identity and link counts are not available here.
|
||||
func ReadDir(path string, chunk int, fn ChunkFunc) error {
|
||||
return readDirGeneric(path, chunk, fn, func(p string) (Meta, error) { return statPath(p, false) })
|
||||
}
|
||||
|
||||
func statPath(path string, follow bool) (Meta, error) {
|
||||
var fi os.FileInfo
|
||||
var err error
|
||||
if follow {
|
||||
fi, err = os.Stat(path)
|
||||
} else {
|
||||
fi, err = os.Lstat(path)
|
||||
}
|
||||
if err != nil {
|
||||
return Meta{}, err
|
||||
}
|
||||
m := fromFileInfo(fi)
|
||||
m.Name = baseName(path)
|
||||
fillSys(&m, fi)
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// IsVirtualFS is Linux-specific; elsewhere nothing is skipped.
|
||||
func IsVirtualFS(string) bool { return false }
|
||||
Reference in New Issue
Block a user