// The IsDirExists judges path is directory or not.
6035
func IsDirExists(path string) bool {
	fi, err := os.Stat(path)

	if err != nil {
		return os.IsExist(err)
	} else {
		return fi.IsDir()
	}

	panic("util isDirExists not reached")
}
847919
func MkdirAll(path string, perm os.FileMode) error {
	twoAttempts := false
	err := os.MkdirAll(path, perm)
	// KBFS-3245: Simple workaround for test flake where a directory
	// seems to disappear out from under us.
	if os.IsNotExist(err) {
		twoAttempts = true
		err = os.MkdirAll(path, perm)
	}
	if err != nil {
		return errors.Wrapf(err,
			"failed to mkdir (all) %q, twoAttempts=%t", path, twoAttempts)
	}

	return nil
}
1049215
func (s *Store) IsDir(ctx context.Context, name string) bool {
	name = s.prefix + name
	out.Debug(ctx, "consul.IsDir(%s)", name)
	count := 0
	ls, err := s.List(ctx, name)
	if err != nil {
		return false
	}
	for _, e := range ls {
		if strings.HasPrefix(e, name) {
			count++
		}
	}
	return count > 1
}
432638
func (l *Loader) IsConfigDir(path string) bool {
	return l.parser.IsConfigDir(path)
}
1325474
func isValidPath(candidatePath string, delgRole data.DelegationRole) bool {
	return candidatePath == "" || delgRole.CheckPaths(candidatePath)
}
193975
func EnsureDirExist(dir string) error {
	exist, err := IsDirExists(dir)
	if !exist || err != nil {
		return os.MkdirAll(dir, 0777)
	}
	return nil
}
1134669
func (s *Store) IsDir(ctx context.Context, name string) bool {
	ls, err := s.List(ctx, name)
	if err != nil {
		return false
	}
	return len(ls) > 1
}
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
	}
}
1011763
func IsURLExists(name string, location string) error {
	parsed, err := url.Parse(location)
	if err != nil {
		return fmt.Errorf("%s is not a valid URL", location)
	}

	// we can only validate if local files exist, not other urls
	if parsed.Scheme != "file" {
		return nil
	}

	// chop off "file://" from the location, giving us the real system path
	sysPath := strings.TrimPrefix(location, "file://")
	stat, err := os.Stat(sysPath)
	if err != nil {
		if os.IsNotExist(err) {
			return fmt.Errorf("%s does not exist", location)
		}

		if os.IsPermission(err) {
			return fmt.Errorf("%s could not be opened (permission error: %s)", location, err.Error())
		}

		return err
	}

	if stat.IsDir() {
		return fmt.Errorf("%s is a directory", location)
	}

	return nil
}
85910
func IsPartitionDir(path string) (bool, error) {
	if _, err := os.Stat(filepath.Join(path, ManifestFileName)); os.IsNotExist(err) {
		return false, nil
	} else if err != nil {
		return false, err
	}
	return true, nil
}
175812
func pathIsFile(path string) bool {
	info, err := os.Stat(path)
	if err != nil {
		return false
	}

	return !info.IsDir()
}
788902
func isCertsDirExists() bool {
	certsDir, err := getCertsDir()
	fatalIf(err.Trace(), "Unable to determine certs folder.")
	if _, e := os.Stat(certsDir); e != nil {
		return false
	}
	return true
}
475861
func DirExists(fs Fs, path string) (bool, error) {
	fi, err := fs.Stat(path)
	if err == nil && fi.IsDir() {
		return true, nil
	}
	if os.IsNotExist(err) {
		return false, nil
	}
	return false, err
}
1104323
func (p Path) IsValid() bool {
	if len(p.Path) < 1 {
		return false
	}

	for _, n := range p.Path {
		if !n.IsValid() {
			return false
		}
	}

	return true
}
407891
func DirExists(filename string) bool {
	fileInfo, err := os.Stat(filename)
	return err == nil && fileInfo.IsDir()
}
278911
func isParentPath(parent, path string) bool {
	rel, err := filepath.Rel(parent, path)
	return err == nil && !strings.HasPrefix(rel, "..")
}
983393
func (r Role) CheckPaths(path string) bool {
	return checkPaths(path, r.Paths)
}