// Overrides the Readdir of the http.File in order to disable showing a list of the dirs/files
357866
func (n noListFile) Readdir(count int) ([]os.FileInfo, error) {
	return nil, nil
}
1260019
func (fs *Filespace) ReadDir(subPath string) ([]os.FileInfo, error) {
	srcNode, err := fs.root.GetByPath(subPath)
	if err != nil {
		return nil, err
	}
	if !srcNode.IsDir() {
		return nil, fmt.Errorf(subPath + " is not a directory")
	}
	var dir = srcNode.(*Dir)
	return dir.GetNodes(), nil
}
98310
func readDirN(dirPath string, count int) (entries []string, err error) {
	bufp := readDirBufPool.Get().(*[]byte)
	buf := *bufp
	defer readDirBufPool.Put(bufp)

	d, err := os.Open(dirPath)
	if err != nil {
		if os.IsNotExist(err) || isSysErrNotDir(err) {
			return nil, errFileNotFound
		}
		if os.IsPermission(err) {
			return nil, errFileAccessDenied
		}
		return nil, err
	}
	defer d.Close()

	fd := int(d.Fd())

	remaining := count
	done := false

	for !done {
		nbuf, err := syscall.ReadDirent(fd, buf)
		if err != nil {
			if isSysErrNotDir(err) {
				return nil, errFileNotFound
			}
			return nil, err
		}
		if nbuf <= 0 {
			break
		}
		var tmpEntries []string
		if tmpEntries, err = parseDirents(dirPath, buf[:nbuf]); err != nil {
			return nil, err
		}
		if count > 0 {
			if remaining <= len(tmpEntries) {
				tmpEntries = tmpEntries[:remaining]
				done = true
			}
			remaining -= len(tmpEntries)
		}
		entries = append(entries, tmpEntries...)
	}
	return
}
825199
func listPassDir(args ...string) ([]os.FileInfo, error) {
	passDir := getPassDir()
	p := path.Join(append([]string{passDir, PASS_FOLDER}, args...)...)
	contents, err := ioutil.ReadDir(p)
	if err != nil {
		if os.IsNotExist(err) {
			return []os.FileInfo{}, nil
		}

		return nil, err
	}

	return contents, nil
}
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)
}
694738
func (c *Client) ReadDir(dirname string) ([]os.FileInfo, error) {
	f, err := c.Open(dirname)
	if err != nil {
		return nil, err
	}

	return f.Readdir(0)
}
1023374
func (f *FilesystemIO) ReadDir(dirname string) ([]os.FileInfo, error) {
	return ioutil.ReadDir(dirname)
}
471386
func (fs *fakeFs) ReadDir(dirname string) ([]os.FileInfo, error) {
	return fs.a.ReadDir(dirname)
}
656699
func (fs DefaultFsEval) Readdir(path string) ([]os.FileInfo, error) {
	fh, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer fh.Close()
	return fh.Readdir(-1)
}
280465
func (f *File) Readdir(count int) ([]os.FileInfo, error) {
	if f.appendedF != nil {
		if f.appendedF.dir {
			fi := make([]os.FileInfo, 0, len(f.appendedF.children))
			for _, childAppendedFile := range f.appendedF.children {
				if childAppendedFile.dir {
					fi = append(fi, childAppendedFile.dirInfo)
				} else {
					fi = append(fi, childAppendedFile.zipFile.FileInfo())
				}
			}
			return fi, nil
		}
		//++ TODO: is os.ErrInvalid the correct error for Readdir on file?
		return nil, os.ErrInvalid
	}
	if f.virtualF != nil {
		return f.virtualF.readdir(count)
	}
	if f.virtualD != nil {
		return f.virtualD.readdir(count)
	}
	return f.realF.Readdir(count)
}
945885
func (l *httpFileSystem) MkDir(path string, mode int) error {
	return trace.BadParameter("directories are not supported in http file transfer")
}
922371
func (g *Git) ReadDir(revision, path string) ([]os.FileInfo, error) {
	if revision == revisionFS {
		return ioutil.ReadDir(path)
	}

	relPath, err := g.rel(path)
	if err != nil {
		return nil, err
	}
	relPath += string(os.PathSeparator)

	args := []string{"--git-dir", g.dir, "ls-tree", revision, relPath}
	ls, err := exec.Command("git", args...).CombinedOutput()
	if err != nil {
		return nil, fmt.Errorf("could not execute git %v, error: %s", args, err)
	}

	var files []os.FileInfo
	for _, file := range bytes.Split(ls, []byte{'\n'}) {
		// 100644 blob 78edbf3fb411055b4a3d4d3d137ccbec160ac956    .gitignore
		// 040000 tree e62f2cac29e1d6e31aeac65ded75df98b9c1be43    testdata
		fields := bytes.Fields(file)
		if len(fields) != 4 {
			continue
		}

		files = append(files, fileInfo{
			// name is basename (no directory structure)
			name: strings.TrimPrefix(string(fields[3]), relPath),
			dir:  bytes.Equal(fields[1], []byte("tree")),
		})
	}
	return files, nil
}
624653
func readDirs(src string) ([]string, error) {
	var files []string

	err := filepath.Walk(src, func(path string, f os.FileInfo, err error) error {
		relativePath := strings.TrimPrefix(path, src)
		if len(relativePath) > 0 {
			files = append(files, relativePath)
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return files, nil
}
363539
func (c *Client) ReadDir(p string) ([]os.FileInfo, error) {
	handle, err := c.opendir(p)
	if err != nil {
		return nil, err
	}
	defer c.close(handle) // this has to defer earlier than the lock below
	var attrs []os.FileInfo
	var done = false
	for !done {
		id := c.nextID()
		typ, data, err1 := c.sendPacket(sshFxpReaddirPacket{
			ID:     id,
			Handle: handle,
		})
		if err1 != nil {
			err = err1
			done = true
			break
		}
		switch typ {
		case ssh_FXP_NAME:
			sid, data := unmarshalUint32(data)
			if sid != id {
				return nil, &unexpectedIDErr{id, sid}
			}
			count, data := unmarshalUint32(data)
			for i := uint32(0); i < count; i++ {
				var filename string
				filename, data = unmarshalString(data)
				_, data = unmarshalString(data) // discard longname
				var attr *FileStat
				attr, data = unmarshalAttrs(data)
				if filename == "." || filename == ".." {
					continue
				}
				attrs = append(attrs, fileInfoFromStat(attr, path.Base(filename)))
			}
		case ssh_FXP_STATUS:
			// TODO(dfc) scope warning!
			err = normaliseError(unmarshalStatus(id, data))
			done = true
		default:
			return nil, unimplementedPacketErr(typ)
		}
	}
	if err == io.EOF {
		err = nil
	}
	return attrs, err
}
539744
func (rfs *RootFS) ReadDir(p string) (fis []os.FileInfo, err error) {
	if p == "" {
		p = "."
	}

	if p != "." {
		return nil, os.ErrNotExist
	}

	now := rfs.config.Clock().Now()
	return []os.FileInfo{
		&wrappedReadFileInfo{"private", 0, now, true},
		&wrappedReadFileInfo{"public", 0, now, true},
		&wrappedReadFileInfo{"team", 0, now, true},
	}, nil
}
145345
func ReadDirectory(dirPath string) (np Netplan, err error) {
	fileInfos, err := ioutil.ReadDir(dirPath)
	if err != nil {
		return np, err
	}
	np.sourceDirectory = dirPath
	sortedFileInfos := sortableFileInfos(fileInfos)
	sort.Sort(sortedFileInfos)
	for _, fileInfo := range sortedFileInfos {
		if !fileInfo.IsDir() && strings.HasSuffix(fileInfo.Name(), ".yaml") {
			np.sourceFiles = append(np.sourceFiles, fileInfo.Name())
		}
	}
	for _, fileName := range np.sourceFiles {
		err := np.readYamlFile(path.Join(np.sourceDirectory, fileName))
		if err != nil {
			return np, err
		}
	}
	return np, nil
}
739697
func readDirNames(dirPath string) ([]string, error) {
	d, err := os.Open(dirPath)
	if err != nil {
		return nil, err
	}
	defer d.Close()

	names, err := d.Readdirnames(-1)
	if err != nil {
		return nil, err
	}
	return names, nil
}