func readDir(fs fuse.FileSystem, name string) *dirResponse { origStream, code := fs.OpenDir(name, nil) r := &dirResponse{nil, code} if !code.Ok() { return r } r.entries = origStream return r }
// newDirnameMap reads the contents of the given directory. On error, // returns a nil map. This forces reloads in the DirCache until we // succeed. func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool { stream, code := fs.OpenDir(dir) if !code.Ok() { log.Printf("newDirnameMap(): %v %v", dir, code) return nil } result := make(map[string]bool) for e := range stream { if e.Mode&fuse.S_IFREG != 0 { result[e.Name] = true } } return result }
func readDir(fs fuse.FileSystem, name string) *dirResponse { origStream, code := fs.OpenDir(name, nil) r := &dirResponse{nil, code} if code != fuse.OK { return r } for { d, ok := <-origStream if !ok { break } r.entries = append(r.entries, d) } return r }
// newDirnameMap reads the contents of the given directory. On error, // returns a nil map. This forces reloads in the DirCache until we // succeed. func newDirnameMap(fs fuse.FileSystem, dir string) map[string]bool { stream, code := fs.OpenDir(dir, nil) if code == fuse.ENOENT { // The directory not existing is not an error. return map[string]bool{} } if !code.Ok() { log.Printf("newDirnameMap(%v): %v %v", fs, dir, code) return nil } result := make(map[string]bool) for _, e := range stream { if e.Mode&fuse.S_IFREG != 0 { result[e.Name] = true } } return result }