elvish/util/rootnames.go

26 lines
337 B
Go
Raw Normal View History

package util
2016-02-09 07:21:31 +08:00
import (
"os"
"sort"
)
// RootNames returns the result of /*.
func RootNames() []string {
f, err := os.Open("/")
if err != nil {
panic(err)
}
names, err := f.Readdirnames(-1)
f.Close()
if err != nil {
panic(err)
}
2016-02-09 07:21:31 +08:00
sort.Strings(names)
for i, name := range names {
names[i] = "/" + name
}
return names
}