// IsDir() checks if the given dir is a directory. If any error is encoutered
// it is returned and directory is set to false.
177002
func IsDir(dirName string) (dir bool, err error) {
	if lstat, err := os.Lstat(dirName); err != nil {
		if os.IsNotExist(err) {
			return false, nil
		}
		return false, err
	} else {
		if !lstat.IsDir() {
			return false, ErrNotADirectory
		}
	}
	return true, nil
}
286003
func IsDirectory(path string) (bool, error) {
	fileInfo, err := os.Stat(path)
	if err != nil {
		return false, errors.Wrapf(err, "Error calling os.Stat on file %s", path)
	}
	return fileInfo.IsDir(), nil
}
290930
func IsDirectory(filePath string) bool {
	stat, err := os.Stat(filePath)
	if err != nil {
		return false
	}
	return stat.IsDir()
}
1310389
func IsNotExist(err error) bool {
	// If it's a bone-fide ENOENT just bail.
	if os.IsNotExist(errors.Cause(err)) {
		return true
	}

	// Check that it's not actually an ENOTDIR, which in some cases is a more
	// convoluted case of ENOENT (usually involving weird paths).
	var errno error
	switch err := errors.Cause(err).(type) {
	case *os.PathError:
		errno = err.Err
	case *os.LinkError:
		errno = err.Err
	case *os.SyscallError:
		errno = err.Err
	}
	return errno == syscall.ENOTDIR || errno == syscall.ENOENT
}
1167915
func (p *Probe) checkDir(c context.Context, dir string, selfDir os.FileInfo, env environ.Env) string {
	// If we have a self directory defined, ensure that "dir" isn't the same
	// directory. If it is, we will ignore this option, since we are looking for
	// something outside of the wrapper directory.
	if selfDir != nil {
		switch checkDirStat, err := os.Stat(dir); {
		case err == nil:
			// "dir" exists; if it is the same as "selfDir", we can ignore it.
			if os.SameFile(selfDir, checkDirStat) {
				logging.Debugf(c, "Candidate shares wrapper directory [%s]; skipping...", dir)
				return ""
			}

		case os.IsNotExist(err):
			logging.Debugf(c, "Candidate directory does not exist [%s]; skipping...", dir)
			return ""

		default:
			logging.Debugf(c, "Failed to stat candidate directory [%s]: %s", dir, err)
			return ""
		}
	}

	t, err := findInDir(p.Target, dir, env)
	if err != nil {
		return ""
	}

	// Make sure this file isn't the same as "self", if available.
	if p.SelfStat != nil {
		switch st, err := os.Stat(t); {
		case err == nil:
			if os.SameFile(p.SelfStat, st) {
				logging.Debugf(c, "Candidate [%s] is same file as wrapper; skipping...", t)
				return ""
			}

		case os.IsNotExist(err):
			// "t" no longer exists, so we can't use it.
			return ""

		default:
			logging.Debugf(c, "Failed to stat candidate path [%s]: %s", t, err)
			return ""
		}
	}

	if err := filesystem.AbsPath(&t); err != nil {
		logging.Debugf(c, "Failed to normalize candidate path [%s]: %s", t, err)
		return ""
	}

	// Try running the candidate command and confirm that it is not a wrapper.
	if p.CheckWrapper != nil {
		switch isWrapper, err := p.CheckWrapper(c, t, env); {
		case err != nil:
			logging.Debugf(c, "Failed to check if [%s] is a wrapper: %s", t, err)
			return ""

		case isWrapper:
			logging.Debugf(c, "Candidate is a wrapper: %s", t)
			return ""
		}
	}

	return t
}
876859
func isFile(name string) (bool, error) {
	info, err := os.Stat(name)
	return err == nil && !info.IsDir(), err
}
1115861
func IsDir(path string) bool {
	finfo, err := os.Stat(path)
	switch {
	case err != nil:
		return false
	case finfo.IsDir():
		return true
	default:
		return false
	}
}
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)
}
667698
func (fs DummyFS) ReadDir(path string) ([]os.FileInfo, error) {
	return nil, fs.err
}
580924
func (fs *FS) ReadDir(path string) ([]os.FileInfo, error) {
	return fs.Filesystem.ReadDir(fs.PrefixPath(path))
}
269
func (u *volumeUtil) IsDir(fullPath string) (bool, error) {
	dir, err := os.Open(fullPath)
	if err != nil {
		return false, err
	}
	defer dir.Close()

	stat, err := dir.Stat()
	if err != nil {
		return false, err
	}

	return stat.IsDir(), nil
}
432469
func (s *FolderStorage) Dir(key string) (d string, e bool, err error) {
	d = s.dir(key)
	_, err = os.Stat(d)
	if err == nil {
		// Directory exists
		e = true
		return
	}
	if os.IsNotExist(err) {
		// Directory doesn't exist
		d = ""
		e = false
		err = nil
		return
	}

	// An error
	d = ""
	e = false
	return
}
370297
func (in *inode) ReadDir(p []byte, offset int) (n int) {
	if !in.isDir() {
		panic("ReadDir called on non-directory.")
	}

	for i := offset; i < len(in.entries); i++ {
		e := in.entries[i]

		// Skip unused entries.
		if e.Type == fuseutil.DT_Unknown {
			continue
		}

		tmp := fuseutil.WriteDirent(p[n:], in.entries[i])
		if tmp == 0 {
			break
		}

		n += tmp
	}

	return
}
488712
func isObjectDir(object string, size int64) bool {
	return hasSuffix(object, slashSeparator) && size == 0
}
891186
func HasConfigDir(ctx context.Context) bool {
	_, ok := ctx.Value(ctxKeyConfigDir).(string)
	return ok
}
17876
func ReadDir(dirname string) ([]os.FileInfo, error) {
	list, err := ioutil_base.ReadDir(dirname)
	if err != nil {
		return nil, errors.Wrapf(err, "failed to read dir %q", dirname)
	}

	return list, nil
}
135044
func checkPathIsDir(ctx context.Context, cli keybase1.SimpleFSInterface, path keybase1.Path) (bool, string, error) {
	var isDir bool
	var pathString string
	var err error

	pathType, _ := path.PathType()
	switch pathType {
	case keybase1.PathType_KBFS, keybase1.PathType_KBFS_ARCHIVED:
		if pathType == keybase1.PathType_KBFS {
			pathString = path.Kbfs()
		} else {
			pathString = path.KbfsArchived().Path
		}
		// See if the dest is a path or file
		destEnt, err := cli.SimpleFSStat(ctx, keybase1.SimpleFSStatArg{Path: path})
		if err != nil {
			return false, "", err
		}

		if destEnt.DirentType == keybase1.DirentType_DIR {
			isDir = true
		}
	case keybase1.PathType_LOCAL:
		pathString = path.Local()
		// An error is OK, could be a target filename
		// that does not exist yet
		fileInfo, err := os.Stat(pathString)
		if err == nil {
			if fileInfo.IsDir() {
				isDir = true
			}
		}
	}
	return isDir, pathString, err
}