func (l *Layer) ListFiles(after string, limit int) ([]File, error) { if limit < 0 { return nil, ErrBadArgument } var query kvl.RangeQuery query.Low = fileKey(after) query.High = keys.PrefixNext(tuple.MustAppend(nil, "file")) if limit > 0 { query.Limit = limit + 1 } pairs, err := l.inner.Range(query) if err != nil { return nil, err } files := make([]File, 0, len(pairs)) for _, pair := range pairs { var f File err := f.fromPair(pair) if err != nil { return nil, err } if f.Path > after { files = append(files, f) if limit > 0 && len(files) == limit { break } } } return files, nil }
func (l *Layer) GetLocationContents(id [16]byte, after string, count int) ([]string, error) { var rang kvl.RangeQuery rang.Low = keys.LexNext(tuple.MustAppend(nil, "locationlist", id, after)) rang.High = keys.PrefixNext(tuple.MustAppend(nil, "locationlist", id)) if count > 0 { rang.Limit = count + 1 } ps, err := l.index.Range(rang) if err != nil { return nil, err } names := make([]string, 0, len(ps)) for _, p := range ps { var typ, name string var loc [16]byte err := tuple.UnpackInto(p.Key, &typ, &loc, &name) if err != nil { return nil, err } if name > after { names = append(names, name) if count > 0 && len(names) >= count { break } } } return names, nil }