diff options
Diffstat (limited to 'modules/options/static.go')
-rw-r--r-- | modules/options/static.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/modules/options/static.go b/modules/options/static.go index f8811e43ac..39f56f42f4 100644 --- a/modules/options/static.go +++ b/modules/options/static.go @@ -113,6 +113,37 @@ func fileFromDir(name string) ([]byte, error) { return ioutil.ReadAll(f) } +func Asset(name string) ([]byte, error) { + f, err := Assets.Open("/" + name) + if err != nil { + return nil, err + } + defer f.Close() + return ioutil.ReadAll(f) +} + +func AssetNames() []string { + realFS := Assets.(vfsgen۰FS) + var results = make([]string, 0, len(realFS)) + for k := range realFS { + results = append(results, k[1:]) + } + return results +} + +func AssetIsDir(name string) (bool, error) { + if f, err := Assets.Open("/" + name); err != nil { + return false, err + } else { + defer f.Close() + if fi, err := f.Stat(); err != nil { + return false, err + } else { + return fi.IsDir(), nil + } + } +} + // IsDynamic will return false when using embedded data (-tags bindata) func IsDynamic() bool { return false |