// The exists function is expected to return true for all known paths
// (excluding "" and ".")
765139
func unifySubs(dirs []string, exists func(dir string) bool) []string {
	if len(dirs) == 0 {
		return nil
	}
	sort.Strings(dirs)
	if dirs[0] == "" || dirs[0] == "." || dirs[0] == string(fs.PathSeparator) {
		return nil
	}
	prev := "./" // Anything that can't be parent of a clean path
	for i := 0; i < len(dirs); {
		dir, err := fs.Canonicalize(dirs[i])
		if err != nil {
			l.Debugf("Skipping %v for scan: %s", dirs[i], err)
			dirs = append(dirs[:i], dirs[i+1:]...)
			continue
		}
		if dir == prev || fs.IsParent(dir, prev) {
			dirs = append(dirs[:i], dirs[i+1:]...)
			continue
		}
		parent := filepath.Dir(dir)
		for parent != "." && parent != string(fs.PathSeparator) && !exists(parent) {
			dir = parent
			parent = filepath.Dir(dir)
		}
		dirs[i] = dir
		prev = dir
		i++
	}
	return dirs
}
1202312
func (d *StateDir) Exists() bool {
	_, err := os.Stat(d.path)
	return err == nil
}
913560
func Exists(args ...string) bool {
	if _, err := Raw(append([]string{"-C"}, args...)...); err != nil {
		return false
	}
	return true
}
1015353
func (d *ExistsResult) Exists() bool {
	return d.keyState != gocbcore.KeyStateNotFound && d.keyState != gocbcore.KeyStateDeleted
}
81025
func (c *Client) Exists(path string) (bool, error) {
	if strings.HasPrefix(path, "s3://") {
		s3Conn, err := s3ConnectionInformation(path, c.Region)
		if err != nil {
			return false, err
		}
		return existsS3(s3Conn)
	}
	return existsLocal(path)
}
1336423
func (r *RedisStore) Exists(key string) (bool, error) {
	cmd := r.client.Exists(key)
	return cmd.Val(), cmd.Err()
}
990887
func (c ConnAdapter) Exists(path string) (bool, *zk.Stat, error) {
	return c.ExistsF(path)
}
833869
func (s *Service) Exists() (bool, error) {
	if s.NoConf() {
		return false, s.errorf(nil, "no conf expected")
	}

	same, err := s.check()
	if err != nil {
		return false, errors.Trace(err)
	}
	return same, nil
}
1044020
func (cd *Codec) Exists(key string) bool {
	return cd.Get(key, nil) == nil
}
1231156
func Exists(execer exec.Interface) bool {
	_, err := execer.LookPath("conntrack")
	return err == nil
}
362199
func (z *zookeeperKV) exists(key string) (bool, error) {
	key = z.domain + normalize(key)
	exists, _, err := z.client.Exists(key)
	if err != nil {
		return false, err
	}
	return exists, nil
}
63142
func Exists(field *gentypes.FieldType) interface{} {
	//u.Debugf("exists?  nested?%v  for %s", field.Nested(), field.String())
	if field.Nested() {
		/*
			"nested": {
				"filter": {
				    "term": {
				        "map_actioncounts.k": "Web hit"
				    }
				},
				"path": "map_actioncounts"
			}
		*/
		return &nested{&NestedFilter{
			Filter: Term(field.Path+".k", field.Field),
			Path:   field.Path,
		}}
		//Nested(field.Path, &term{map[string][]string{"k": field.Field}})
	}
	return &exists{map[string]string{"field": field.Field}}
}
104296
func (m *Multi) Exists(name string) (string, bool) {
	for _, loader := range m.loaders {
		if fileName, ok := loader.Exists(name); ok {
			return fileName, true
		}
	}
	return "", false
}
690186
func (db *RedisDB) Exists(k string) bool {
	db.master.Lock()
	defer db.master.Unlock()
	return db.exists(k)
}
617531
func (d *NFSDriver) Exists(volumeName string) bool {
	var (
		fi  os.FileInfo
		err error
	)
	if fi, err = os.Stat(filepath.Join(d.root, volumeName)); err != nil {
		return false
	}
	return fi.IsDir()
}
337826
func (c *ZkConn) Exists(ctx context.Context, path string) (exists bool, stat *zk.Stat, err error) {
	err = c.withRetry(ctx, func(conn *zk.Conn) error {
		exists, stat, err = conn.Exists(path)
		return err
	})
	return
}
101655
func (s *Store) Exists(ctx context.Context, name string) bool {
	_, err := s.Get(ctx, name)
	return err == nil
}