Start loading .fnt files. No display yet

This commit is contained in:
2019-01-02 06:16:15 +00:00
parent 568365be3a
commit 997e2076d1
6 changed files with 340 additions and 19 deletions

29
internal/util/file.go Normal file
View File

@@ -0,0 +1,29 @@
package util
import (
"io/ioutil"
"path/filepath"
"strings"
)
// DirByExt returns entries in a directory with the specified extension
func DirByExt(dir, ext string) ([]string, error) {
fis, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}
out := make([]string, 0, len(fis))
for _, fi := range fis {
relname := fi.Name()
extname := filepath.Ext(relname)
// Skip anything that doesn't match the extension
if strings.EqualFold(extname, ext) {
out = append(out, relname)
}
}
return out, nil
}