2016-02-17 02:14:05 +08:00
|
|
|
package util
|
2016-02-09 06:57:30 +08:00
|
|
|
|
2016-02-09 07:21:31 +08:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"sort"
|
|
|
|
)
|
2016-02-09 06:57:30 +08:00
|
|
|
|
|
|
|
// RootNames returns the result of /*.
|
2016-02-23 09:45:35 +08:00
|
|
|
func RootStar() []string {
|
2016-02-09 06:57:30 +08:00
|
|
|
f, err := os.Open("/")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
names, err := f.Readdirnames(-1)
|
|
|
|
f.Close()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2016-02-23 09:45:35 +08:00
|
|
|
|
|
|
|
var newnames []string
|
|
|
|
for _, name := range names {
|
2016-02-23 10:02:23 +08:00
|
|
|
if name[0] != '.' {
|
2016-02-23 09:45:35 +08:00
|
|
|
newnames = append(newnames, "/"+name)
|
|
|
|
}
|
2016-02-09 06:57:30 +08:00
|
|
|
}
|
2016-02-23 09:45:35 +08:00
|
|
|
|
|
|
|
sort.Strings(newnames)
|
|
|
|
return newnames
|
2016-02-09 06:57:30 +08:00
|
|
|
}
|