Start loading .fnt files. No display yet
This commit is contained in:
29
internal/util/file.go
Normal file
29
internal/util/file.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user