AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy: data/ foo.txt img/ a.png b.png then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") wou
(name string)
| 993 | // AssetDir("foo.txt") and AssetDir("notexist") would return an error |
| 994 | // AssetDir("") will return []string{"data"}. |
| 995 | func AssetDir(name string) ([]string, error) { |
| 996 | node := _bintree |
| 997 | if len(name) != 0 { |
| 998 | cannonicalName := strings.Replace(name, "\\", "/", -1) |
| 999 | pathList := strings.Split(cannonicalName, "/") |
| 1000 | for _, p := range pathList { |
| 1001 | node = node.Children[p] |
| 1002 | if node == nil { |
| 1003 | return nil, fmt.Errorf("Asset %s not found", name) |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | if node.Func != nil { |
| 1008 | return nil, fmt.Errorf("Asset %s not found", name) |
| 1009 | } |
| 1010 | rv := make([]string, 0, len(node.Children)) |
| 1011 | for childName := range node.Children { |
| 1012 | rv = append(rv, childName) |
| 1013 | } |
| 1014 | return rv, nil |
| 1015 | } |
| 1016 | |
| 1017 | type bintree struct { |
| 1018 | Func func() (*asset, error) |