/*
DirContains returns true if the dir contains the path. Calls t.Error if
something goes wrong while checking.
*/
196008
func DirContains(t TestReporter, dir string, path string) bool {
	fullPath := filepath.Join(dir, path)
	return Exists(t, fullPath)
}
27697
func SliceContainsString(slice []string, str string) bool {
	for _, value := range slice {
		if value == str {
			return true
		}
	}
	return false
}
1060268
func DirCheck(filePath string) error {
	dir := filepath.Dir(filePath)
	if !FileExists(dir) {
		return os.MkdirAll(dir, 0777)
	}
	return nil
}
232014
func (s *PathSpec) Validate() error {
	if s.Local() {
		info, err := os.Stat(s.Path)
		if err != nil {
			return fmt.Errorf("invalid path %s: %v", s.Path, err)
		}
		if !info.IsDir() {
			return fmt.Errorf("path %s must point to a directory", s.Path)
		}
	}
	return nil
}
861183
func DirExists(path string) bool {
	st, err := os.Stat(path)
	return err == nil && st.IsDir()
}
1126581
func TitleContains(tab *Tab, searchTitle string) ConditionalFunc {
	return func(tab *Tab) bool {
		if pageTitle, err := tab.GetTitle(); err == nil && strings.Contains(pageTitle, searchTitle) {
			return true
		}
		return false
	}
}
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")
}
856470
func IsDir(dir string) bool {
	f, e := os.Stat(dir)
	if e != nil {
		return false
	}
	return f.IsDir()
}
1211138
func NotContains(t testing.TB, container, item interface{}, args ...interface{}) {
	assert(t, !IsContains(container, item), args,
		[]interface{}{"container:[%v]包含item[%v]", container, item})
}
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
}
406607
func FilterContains(completions []Suggest, sub string, ignoreCase bool) []Suggest {
	return filterSuggestions(completions, sub, ignoreCase, strings.Contains)
}
641123
func deriveContains(list []int, item int) bool {
	for _, v := range list {
		if v == item {
			return true
		}
	}
	return false
}
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
	}
}
839803
func checkForNonDirectories(path string) error {
	p := "/"
	for _, component := range util.SplitPath(path) {
		p = filepath.Join(p, component)
		st, err := os.Lstat(p)
		if err != nil && os.IsNotExist(err) {
			return nil // nonexistent is ok
		} else if err != nil {
			return err
		}
		if !st.Mode().IsDir() {
			return fmt.Errorf("Mount path %q contains non-directory component %q", path, p)
		}
	}
	return nil
}
945028
func hasDirPrefix(dirPrefix, fullpath string) bool {
	if !strings.HasPrefix(fullpath, dirPrefix) {
		return false
	}
	if len(fullpath) == len(dirPrefix) {
		return true
	}
	if fullpath[len(dirPrefix)] == filepath.Separator {
		return true
	}
	return false
}
402531
func (d *S3Driver) DirContents(path string) ([]os.FileInfo, bool) {
	moreObjects := true
	var objects []*s3.Object

	var resp *s3.ListObjectsOutput
	var err error
	marker := ""

	for moreObjects {
		resp, err = d.s3DirContents(path, 1000, marker)

		if err == nil {
			for _, obj := range resp.Contents {
				objects = append(objects, obj)
			}

			moreObjects = *resp.IsTruncated

			if moreObjects {
				last := objects[len(objects)-1]
				marker = *last.Key
			}
		}
	}

	prefix := pathToS3PathPrefix(path)
	var files []os.FileInfo
	var dirs []string

	for _, object := range objects {
		p := *object.Key

		p = strings.TrimPrefix(p, *prefix)
		var fi os.FileInfo

		if strings.Contains(p, "/") || p == "" {

			parts := strings.Split(p, "/")
			dirPart := parts[0]

			if dirPart != d.WorkingDirectory && dirPart != "" && dirPart != "/" && !stringInSlice(dirPart, dirs) {
				fi = graval.NewDirItem(dirPart)
				files = append(files, fi)

				dirs = append(dirs, dirPart)
			}
		} else {
			fi = graval.NewFileItem(*object.Key, *object.Size, *object.LastModified)
			files = append(files, fi)
		}
	}

	return files, true
}
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
}