elvish/util/rootstar.go
2016-02-23 03:02:23 +01:00

31 lines
410 B
Go

package util
import (
"os"
"sort"
)
// RootNames returns the result of /*.
func RootStar() []string {
f, err := os.Open("/")
if err != nil {
panic(err)
}
names, err := f.Readdirnames(-1)
f.Close()
if err != nil {
panic(err)
}
var newnames []string
for _, name := range names {
if name[0] != '.' {
newnames = append(newnames, "/"+name)
}
}
sort.Strings(newnames)
return newnames
}