1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package themes
import (
"os"
"path/filepath"
)
type Theme struct {
Name string
Path string
}
func List(themesDir string) ([]Theme, error) {
entries, err := os.ReadDir(themesDir)
if err != nil {
return nil, err
}
var themes []Theme
for _, entry := range entries {
if entry.IsDir() {
themes = append(themes, Theme{
Name: entry.Name(),
Path: filepath.Join(themesDir, entry.Name()),
})
}
}
return themes, nil
}
func GetThemePath(themesDir, themeName string) string {
return filepath.Join(themesDir, themeName)
}
func ThemeExists(themesDir, themeName string) bool {
path := GetThemePath(themesDir, themeName)
info, err := os.Stat(path)
return err == nil && info.IsDir()
}
|