// ReadDirAll implements the ReadDirAll interface.
979890
func (fl *FolderList) ReadDirAll(ctx context.Context) (res []fuse.Dirent, err error) {
	fl.fs.vlog.CLogf(ctx, libkb.VLog1, "FL ReadDirAll")
	defer func() {
		err = fl.fs.processError(ctx, libkbfs.ReadMode, err)
	}()
	session, err := fl.fs.config.KBPKI().GetCurrentSession(ctx)
	isLoggedIn := err == nil

	var favs []favorites.Folder
	if isLoggedIn {
		favs, err = fl.fs.config.KBFSOps().GetFavorites(ctx)
		if err != nil {
			return nil, err
		}
	}

	res = make([]fuse.Dirent, 0, len(favs))
	for _, fav := range favs {
		if fav.Type != fl.tlfType {
			continue
		}
		pname, err := tlf.CanonicalToPreferredName(
			session.Name, tlf.CanonicalName(fav.Name))
		if err != nil {
			fl.fs.log.Errorf("CanonicalToPreferredName: %q %v", fav.Name, err)
			continue
		}
		res = append(res, fuse.Dirent{
			Type: fuse.DT_Dir,
			Name: string(pname),
		})
	}
	return res, nil
}
39238
func (fs *Filespace) MkdirAll(subPath string, filemode os.FileMode) error {
	return disk.MkdirAll(fs.path+subPath, filemode)
}
921139
func (dr *DirReader) Readdir(ctx context.Context, n int) (entries []DirectoryEntry, err error) {
	sts, err := dr.StaticSet(ctx)
	if err != nil {
		return nil, fmt.Errorf("schema/dirreader: can't get StaticSet: %v", err)
	}
	up := dr.current + n
	if n <= 0 {
		dr.current = 0
		up = len(sts)
	} else {
		if n > (len(sts) - dr.current) {
			err = io.EOF
			up = len(sts)
		}
	}

	// TODO(bradfitz): push down information to the fetcher
	// (e.g. cachingfetcher -> remote client http) that we're
	// going to load a bunch, so the HTTP client (if not using
	// SPDY) can do discovery and see if the server supports a
	// batch handler, then get them all in one round-trip, rather
	// than attacking the server with hundreds of parallel TLS
	// setups.

	type res struct {
		ent DirectoryEntry
		err error
	}
	var cs []chan res

	// Kick off all directory entry loads.
	gate := syncutil.NewGate(20) // Limit IO concurrency
	for _, entRef := range sts[dr.current:up] {
		c := make(chan res, 1)
		cs = append(cs, c)
		gate.Start()
		go func(entRef blob.Ref) {
			defer gate.Done()
			entry, err := NewDirectoryEntryFromBlobRef(ctx, dr.fetcher, entRef)
			c <- res{entry, err}
		}(entRef)
	}

	for _, c := range cs {
		res := <-c
		if res.err != nil {
			return nil, fmt.Errorf("schema/dirreader: can't create dirEntry: %v", res.err)
		}
		entries = append(entries, res.ent)
	}
	return entries, nil
}
22101
func (f *StandaloneFile) ReadFile() ([]byte, error) {
	return f.filespace.ReadFile(f.path)
}
1023374
func (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error) {
	return ioutil.ReadDir(dirname)
}
557836
func (s *Node) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	log.Debug("Node ReadDir")
	dir, err := uio.NewDirectoryFromNode(s.Ipfs.DAG, s.Nd)
	if err != nil {
		return nil, err
	}

	var entries []fuse.Dirent
	err = dir.ForEachLink(ctx, func(lnk *ipld.Link) error {
		n := lnk.Name
		if len(n) == 0 {
			n = lnk.Cid.String()
		}
		nd, err := s.Ipfs.DAG.Get(ctx, lnk.Cid)
		if err != nil {
			log.Warning("error fetching directory child node: ", err)
		}

		t := fuse.DT_Unknown
		switch nd := nd.(type) {
		case *mdag.RawNode:
			t = fuse.DT_File
		case *mdag.ProtoNode:
			if fsn, err := ft.FSNodeFromBytes(nd.Data()); err != nil {
				log.Warning("failed to unmarshal protonode data field:", err)
			} else {
				switch fsn.Type() {
				case ft.TDirectory, ft.THAMTShard:
					t = fuse.DT_Dir
				case ft.TFile, ft.TRaw:
					t = fuse.DT_File
				case ft.TSymlink:
					t = fuse.DT_Link
				case ft.TMetadata:
					log.Error("metadata object in fuse should contain its wrapped type")
				default:
					log.Error("unrecognized protonode data type: ", fsn.Type())
				}
			}
		}
		entries = append(entries, fuse.Dirent{Name: n, Type: t})
		return nil
	})
	if err != nil {
		return nil, err
	}

	if len(entries) > 0 {
		return entries, nil
	}
	return nil, fuse.ENOENT
}
1041095
func MkdirAll(fs VFS, path string, perm os.FileMode) error {
	cur := "/"
	if err := makeDir(fs, cur, perm); err != nil {
		return err
	}
	parts := strings.Split(path, "/")
	for _, v := range parts {
		cur += v
		if err := makeDir(fs, cur, perm); err != nil {
			return err
		}
		cur += "/"
	}
	return nil
}
674437
func (c *Context) ReadDir(path string) ([]proto.FileInfo, error) {
	if ae != nil {
		return ae.ReadDir(c.ae, path)
	}
	return c.readdir(path)
}
1231095
func readFileOrURL(workingDir, fileName string) ([]byte, error) {
	// read from URL if it is an URL, otherwise read from local file.
	if isURL(fileName) {
		return readURL(fileName)
	}
	return readFileContents(workingDir, fileName)
}
580924
func (fs *FS) ReadDir(path string) ([]os.FileInfo, error) {
	return fs.Filesystem.ReadDir(fs.PrefixPath(path))
}
958570
func (fs *errorFS) ReadDir(
	ctx context.Context,
	op *fuseops.ReadDirOp) (err error) {
	if fs.transformError(op, &err) {
		return
	}

	if op.Inode != fuseops.RootInodeID || op.Offset != 0 {
		err = fmt.Errorf("Unexpected request: %#v", op)
		return
	}

	op.BytesRead = fuseutil.WriteDirent(
		op.Dst,
		fuseutil.Dirent{
			Offset: 0,
			Inode:  fooInodeID,
			Name:   "foo",
			Type:   fuseutil.DT_File,
		})

	return
}
321043
func (d *Dir) MkdirAll(subPath string, filemode os.FileMode) error {
	pathNodes := strings.Split(path.Clean(subPath), "/")
	currentNode := d
	for i, nodeName := range pathNodes {
		newCurrentNode, err := currentNode.GetNode(nodeName)
		if err == nil {
			// get exist path node
			if !newCurrentNode.IsDir() {
				return fmt.Errorf(nodeName + " exists and is not dir in path " + subPath)
			}
			currentNode = newCurrentNode.(*Dir)
			continue
		}
		//create directories
		var subDir *Dir
		for i2 := len(pathNodes) - 1; i2 >= i; i2-- {
			newSubDir := &Dir{
				name:     pathNodes[i2],
				filemode: filemode,
				time:     time.Now(),
				nodes:    []os.FileInfo{},
			}
			if subDir != nil {
				newSubDir.AddNode(subDir)
			}
			subDir = newSubDir
		}
		currentNode.AddNode(subDir)
		return nil
	}
	return nil
}
1040166
func readDir(dirname string) ([]os.FileInfo, error) {
	f, e := os.Open(dirname)
	if e != nil {
		return nil, e
	}
	list, e := f.Readdir(-1)
	if e != nil {
		return nil, e
	}
	if e = f.Close(); e != nil {
		return nil, e
	}
	sort.Sort(byDirName(list))
	return list, nil
}
227839
func (c *Client) MkdirAll(path string) error {
	// Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13
	// Fast path: if we can tell whether path is a directory or file, stop with success or error.
	dir, err := c.Stat(path)
	if err == nil {
		if dir.IsDir() {
			return nil
		}
		return &os.PathError{Op: "mkdir", Path: path, Err: syscall.ENOTDIR}
	}

	// Slow path: make sure parent exists and then call Mkdir for path.
	i := len(path)
	for i > 0 && os.IsPathSeparator(path[i-1]) { // Skip trailing path separator.
		i--
	}

	j := i
	for j > 0 && !os.IsPathSeparator(path[j-1]) { // Scan backward over element.
		j--
	}

	if j > 1 {
		// Create parent
		err = c.MkdirAll(path[0 : j-1])
		if err != nil {
			return err
		}
	}

	// Parent now exists; invoke Mkdir and use its result.
	err = c.Mkdir(path)
	if err != nil {
		// Handle arguments like "foo/." by
		// double-checking that directory doesn't exist.
		dir, err1 := c.Lstat(path)
		if err1 == nil && dir.IsDir() {
			return nil
		}
		return err
	}
	return nil
}
543098
func (f *FakeFS) MkdirAll(dirName string, perm os.FileMode) error {
	_, err := f.Create(dirName)
	return err
}
518098
func (f *File) Readdir() ([]*File, error) {
	if !f.IsDir() {
		return nil, errors.New("not a directory")
	}
	return f.img.readdir(f.subdirOffset)
}
420269
func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	var entries []fuse.Dirent
	listing, err := dir.dir.List(ctx)
	if err != nil {
		return nil, err
	}
	for _, entry := range listing {
		dirent := fuse.Dirent{Name: entry.Name}

		switch mfs.NodeType(entry.Type) {
		case mfs.TDir:
			dirent.Type = fuse.DT_Dir
		case mfs.TFile:
			dirent.Type = fuse.DT_File
		}

		entries = append(entries, dirent)
	}

	if len(entries) > 0 {
		return entries, nil
	}
	return nil, fuse.ENOENT
}