more refactoring

This commit is contained in:
2025-05-10 23:01:08 -04:00
parent 7956c84a94
commit ef8bf980ce
2 changed files with 58 additions and 49 deletions

View File

@@ -2,6 +2,10 @@ package filetypes
import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
tk "modernc.org/tk9.0"
)
@@ -95,3 +99,19 @@ func GetTkTypes(fds []FileDescription) []tk.FileType {
}
return fts
}
func IsImage(entry os.DirEntry) bool {
if entry.IsDir() {
return false
}
ext := filepath.Ext(entry.Name())
if ext == "" {
return false
}
for _, ft := range Valid {
if slices.Contains(ft.MacExtensions, strings.ToLower(ext[1:])) {
return true
}
}
return false
}