// PrefixList is used to do a PrefixList search over quota usages
16347
func (q *Quotas) PrefixListUsage(prefix string, qo *QueryOptions) ([]*QuotaUsage, *QueryMeta, error) {
	if qo == nil {
		qo = &QueryOptions{Prefix: prefix}
	} else {
		qo.Prefix = prefix
	}

	return q.ListUsage(qo)
}
306237
func PrefixFilter(prefix string) FilterFunc {
	return func(m *Info) (bool, bool) {
		skip := !strings.HasPrefix(m.Mountpoint, prefix)
		return skip, false
	}
}
2929
func isPathInPrefixList(path string, prefix []string) bool {
	for _, p := range prefix {
		if strings.HasPrefix(path, p+"/") {
			return false
		}
	}
	return true
}
746783
func (m *MantaBackend) List(ctx context.Context, prefix string) ([]string, error) {
	defer metrics.MeasureSince([]string{"manta", "list"}, time.Now())

	m.permitPool.Acquire()
	defer m.permitPool.Release()

	objs, err := m.client.Dir().List(ctx, &storage.ListDirectoryInput{
		DirectoryName: path.Join(mantaDefaultRootStore, m.directory, prefix),
	})
	if err != nil {
		if errors.IsResourceNotFound(err) {
			return []string{}, nil
		}
		return nil, err
	}

	keys := []string{}
	for _, obj := range objs.Entries {
		if obj.Type == "directory" {
			objs, err := m.client.Dir().List(ctx, &storage.ListDirectoryInput{
				DirectoryName: path.Join(mantaDefaultRootStore, m.directory, prefix, obj.Name),
			})
			if err != nil {
				if !errors.IsResourceNotFound(err) {
					return nil, err
				}
			}

			//We need to check to see if there is something more than just the `value` file
			//if the length of the children is:
			// > 1 and includes the value `index` then we need to add foo and foo/
			// = 1 and the value is `index` then we need to add foo
			// = 1 and the value is not `index` then we need to add foo/
			if len(objs.Entries) == 1 {
				if objs.Entries[0].Name != ".vault_value" {
					keys = append(keys, fmt.Sprintf("%s/", obj.Name))
				} else {
					keys = append(keys, obj.Name)
				}
			} else if len(objs.Entries) > 1 {
				for _, childObj := range objs.Entries {
					if childObj.Name == ".vault_value" {
						keys = append(keys, obj.Name)
					} else {
						keys = append(keys, fmt.Sprintf("%s/", obj.Name))
					}
				}
			} else {
				keys = append(keys, obj.Name)
			}
		}
	}

	sort.Strings(keys)

	return keys, nil
}
264560
func (n *node) PrefixScan(prefix string) []Node {
	if n.tx != nil {
		return n.prefixScan(n.tx, prefix)
	}

	var nodes []Node

	n.readTx(func(tx *bolt.Tx) error {
		nodes = n.prefixScan(tx, prefix)
		return nil
	})

	return nodes
}
606972
func prefixName(prefix, name string) string {
	if prefix != "" {
		name = prefix + "." + name
	}
	return name
}
1167274
func (m *MySQLBackend) List(ctx context.Context, prefix string) ([]string, error) {
	defer metrics.MeasureSince([]string{"mysql", "list"}, time.Now())

	m.permitPool.Acquire()
	defer m.permitPool.Release()

	// Add the % wildcard to the prefix to do the prefix search
	likePrefix := prefix + "%"
	rows, err := m.statements["list"].Query(likePrefix)
	if err != nil {
		return nil, errwrap.Wrapf("failed to execute statement: {{err}}", err)
	}

	var keys []string
	for rows.Next() {
		var key string
		err = rows.Scan(&key)
		if err != nil {
			return nil, errwrap.Wrapf("failed to scan rows: {{err}}", err)
		}

		key = strings.TrimPrefix(key, prefix)
		if i := strings.Index(key, "/"); i == -1 {
			// Add objects only from the current 'folder'
			keys = append(keys, key)
		} else if i != -1 {
			// Add truncated 'folder' paths
			keys = strutil.AppendIfMissing(keys, string(key[:i+1]))
		}
	}

	sort.Strings(keys)
	return keys, nil
}
474835
func (ps *PrefixScanner) Items() (items []Item, err error) {
	pre := ps.Prefix
	err = ps.db.View(func(tx *bolt.Tx) error {
		c := tx.Bucket(ps.BucketName).Cursor()
		for k, v := c.Seek(pre); bytes.HasPrefix(k, pre); k, v = c.Next() {
			items = append(items, Item{k, v})
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	return items, err
}
139832
func (n *node) Prefix(fieldName string, prefix string, to interface{}, options ...func(*index.Options)) error {
	sink, err := newListSink(n, to)
	if err != nil {
		return err
	}

	bucketName := sink.bucketName()
	if bucketName == "" {
		return ErrNoName
	}

	ref := reflect.Indirect(reflect.New(sink.elemType))
	cfg, err := extractSingleField(&ref, fieldName)
	if err != nil {
		return err
	}

	opts := index.NewOptions()
	for _, fn := range options {
		fn(opts)
	}

	field, ok := cfg.Fields[fieldName]
	if !ok || (!field.IsID && field.Index == "") {
		query := newQuery(n, q.Re(fieldName, fmt.Sprintf("^%s", prefix)))
		query.Skip(opts.Skip).Limit(opts.Limit)

		if opts.Reverse {
			query.Reverse()
		}

		err = n.readTx(func(tx *bolt.Tx) error {
			return query.query(tx, sink)
		})

		if err != nil {
			return err
		}

		return sink.flush()
	}

	prfx, err := toBytes(prefix, n.codec)
	if err != nil {
		return err
	}

	return n.readTx(func(tx *bolt.Tx) error {
		return n.prefix(tx, bucketName, fieldName, cfg, sink, prfx, opts)
	})
}
458216
func (p *parser) prefixType(reg TypeRegistry, t *Type, prefix string) *Type {
	pre := TypeName(prefix)
	switch t.Variant {
	case TypeVariantAliasTypeDef:
		t.AliasTypeDef.Name = pre + t.AliasTypeDef.Name
		if !reg.IsBaseTypeName(t.AliasTypeDef.Type) {
			t.AliasTypeDef.Type = TypeRef(pre) + t.AliasTypeDef.Type
		}
	case TypeVariantStringTypeDef:
		t.StringTypeDef.Name = pre + t.StringTypeDef.Name
		if !reg.IsBaseTypeName(t.StringTypeDef.Type) {
			t.StringTypeDef.Type = TypeRef(pre) + t.StringTypeDef.Type
		}
	case TypeVariantNumberTypeDef:
		t.NumberTypeDef.Name = pre + t.NumberTypeDef.Name
		if !reg.IsBaseTypeName(t.NumberTypeDef.Type) {
			t.NumberTypeDef.Type = TypeRef(pre) + t.NumberTypeDef.Type
		}
	case TypeVariantArrayTypeDef:
		t.ArrayTypeDef.Name = pre + t.ArrayTypeDef.Name
		if !reg.IsBaseTypeName(t.ArrayTypeDef.Type) {
			t.ArrayTypeDef.Type = TypeRef(pre) + t.ArrayTypeDef.Type
		}
		if !reg.IsBaseTypeName(t.ArrayTypeDef.Items) {
			t.ArrayTypeDef.Items = TypeRef(pre) + t.ArrayTypeDef.Items
		}
	case TypeVariantMapTypeDef:
		t.MapTypeDef.Name = pre + t.MapTypeDef.Name
		if !reg.IsBaseTypeName(t.MapTypeDef.Type) {
			t.MapTypeDef.Type = TypeRef(pre) + t.MapTypeDef.Type
		}
		if t.MapTypeDef.Keys != "" && !reg.IsBaseTypeName(t.MapTypeDef.Keys) {
			t.MapTypeDef.Keys = TypeRef(pre) + t.MapTypeDef.Keys
		}
		if t.MapTypeDef.Items != "" && !reg.IsBaseTypeName(t.MapTypeDef.Items) {
			t.MapTypeDef.Items = TypeRef(pre) + t.MapTypeDef.Items
		}
	case TypeVariantStructTypeDef:
		t.StructTypeDef.Name = pre + t.StructTypeDef.Name
		if !reg.IsBaseTypeName(t.StructTypeDef.Type) {
			t.StructTypeDef.Type = TypeRef(pre) + t.StructTypeDef.Type
		}
		for _, f := range t.StructTypeDef.Fields {
			if !reg.IsBaseTypeName(f.Type) {
				f.Type = TypeRef(pre) + f.Type
			}
			if f.Keys != "" && !reg.IsBaseTypeName(f.Keys) {
				f.Keys = TypeRef(pre) + f.Keys
			}
			if f.Items != "" && !reg.IsBaseTypeName(f.Items) {
				f.Items = TypeRef(pre) + f.Items
			}
		}
	case TypeVariantBytesTypeDef:
		t.BytesTypeDef.Name = pre + t.BytesTypeDef.Name
		if !reg.IsBaseTypeName(t.BytesTypeDef.Type) {
			t.BytesTypeDef.Type = TypeRef(pre) + t.BytesTypeDef.Type
		}
	case TypeVariantEnumTypeDef:
		t.EnumTypeDef.Name = pre + t.EnumTypeDef.Name
		if !reg.IsBaseTypeName(t.EnumTypeDef.Type) {
			t.EnumTypeDef.Type = TypeRef(pre) + t.EnumTypeDef.Type
		}
	case TypeVariantUnionTypeDef:
		t.UnionTypeDef.Name = pre + t.UnionTypeDef.Name
		if !reg.IsBaseTypeName(t.UnionTypeDef.Type) {
			t.UnionTypeDef.Type = TypeRef(pre) + t.UnionTypeDef.Type
		}
		for i := 0; i < len(t.UnionTypeDef.Variants); i++ {
			if !reg.IsBaseTypeName(t.UnionTypeDef.Variants[i]) {
				t.UnionTypeDef.Variants[i] = TypeRef(pre) + t.UnionTypeDef.Variants[i]
			}
		}
	case TypeVariantBaseType:
		return nil
	}
	return t
}
601429
func PrefixLines(s string, prefix string) string {
	lines := strings.Split(s, "\n")
	for i, l := range lines {
		lines[i] = prefix + l
	}
	return strings.Join(lines, "\n")
}
212408
func (t *Trie) PrefixMembersList(prefix string) (members []string) {
	for _, mi := range t.Root.prefixMembers([]byte{}, []byte(prefix)) {
		members = append(members, mi.Value)
	}
	return
}
643053
func (m *InMem) List(ctx context.Context, prefix string) ([]string, error) {
	m.Lock()
	defer m.Unlock()

	keys := make([]string, 0, len(m.data))
	for k := range m.data {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys, nil
}
583377
func (c *CassandraBackend) List(ctx context.Context, prefix string) ([]string, error) {
	defer metrics.MeasureSince([]string{"cassandra", "list"}, time.Now())

	stmt := fmt.Sprintf(`SELECT key FROM "%s" WHERE bucket = ?`, c.table)
	q := c.sess.Query(stmt, c.bucketName(prefix))
	iter := q.Iter()
	k, keys := "", []string{}
	for iter.Scan(&k) {
		// Only return the next "component" (with a trailing slash if it has children)
		k = strings.TrimPrefix(k, prefix)
		if parts := strings.SplitN(k, "/", 2); len(parts) > 1 {
			k = parts[0] + "/"
		} else {
			k = parts[0]
		}

		// Deduplicate; this works because the keys are sorted
		if len(keys) > 0 && keys[len(keys)-1] == k {
			continue
		}
		keys = append(keys, k)
	}
	return keys, iter.Close()
}
290191
func blocklistItem(name string) string {
	base := filepath.Base(name)

	for _, p := range prefixBlocklist {
		if strings.HasPrefix(base, p) {
			return p
		}
	}

	return ""
}
1118771
func (s *Store) List(ctx context.Context, prefix string) ([]string, error) {
	if s.storage == nil || s.crypto == nil {
		return nil, nil
	}

	lst, err := s.storage.List(ctx, prefix)
	if err != nil {
		return nil, err
	}
	out.Debug(ctx, "sub.List(%s): %+v\n", prefix, lst)
	out := make([]string, 0, len(lst))
	cExt := "." + s.crypto.Ext()
	for _, path := range lst {
		if !strings.HasSuffix(path, cExt) {
			continue
		}
		path = strings.TrimSuffix(path, cExt)
		if s.alias != "" {
			path = s.alias + sep + path
		}
		out = append(out, path)
	}
	return out, nil
}
1222070
func (b *Backend) List(ctx context.Context, prefix string) ([]string, error) {
	defer metrics.MeasureSince(metricList, time.Now())

	// Pooling
	b.permitPool.Acquire()
	defer b.permitPool.Release()

	iter := b.client.Bucket(b.bucket).Objects(ctx, &storage.Query{
		Prefix:    prefix,
		Delimiter: objectDelimiter,
		Versions:  false,
	})

	keys := []string{}

	for {
		objAttrs, err := iter.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return nil, errwrap.Wrapf("failed to read object: {{err}}", err)
		}

		var path string
		if objAttrs.Prefix != "" {
			// "subdirectory"
			path = objAttrs.Prefix
		} else {
			// file
			path = objAttrs.Name
		}

		// get relative file/dir just like "basename"
		key := strings.TrimPrefix(path, prefix)
		keys = append(keys, key)
	}

	sort.Strings(keys)

	return keys, nil
}