mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
26 lines
644 B
Go
26 lines
644 B
Go
// Package fileutil provides utility methods used when dealing with the filesystem in tsdb.
|
|
// It is largely copied from github.com/coreos/etcd/pkg/fileutil to avoid the
|
|
// dependency chain it brings with it.
|
|
// Please check github.com/coreos/etcd for licensing information.
|
|
package fileutil
|
|
|
|
import (
|
|
"os"
|
|
"sort"
|
|
)
|
|
|
|
// ReadDir returns the filenames in the given directory in sorted order.
|
|
func ReadDir(dirpath string) ([]string, error) {
|
|
dir, err := os.Open(dirpath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer dir.Close()
|
|
names, err := dir.Readdirnames(-1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
sort.Strings(names)
|
|
return names, nil
|
|
}
|