elvish/util/rootstar.go

31 lines
410 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 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 {
2016-02-23 10:02:23 +08:00
if name[0] != '.' {
newnames = append(newnames, "/"+name)
}
}
sort.Strings(newnames)
return newnames
}