Added support for profiling. Removed the pkg module altogether. Everything except old sync is now using code generated by sqlc.
36 lines
720 B
Go
36 lines
720 B
Go
package backend
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func GetCharacters() []string {
|
|
musicPath := os.Getenv("MUSIC_PATH")
|
|
charactersPath := musicPath + "characters/"
|
|
files, err := os.ReadDir(charactersPath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
var characters []string
|
|
for _, file := range files {
|
|
if isImage(file) {
|
|
characters = append(characters, file.Name())
|
|
}
|
|
}
|
|
return characters
|
|
}
|
|
|
|
func GetCharacter(character string) string {
|
|
musicPath := os.Getenv("MUSIC_PATH")
|
|
charactersPath := musicPath + "characters/"
|
|
return charactersPath + character
|
|
}
|
|
|
|
func isImage(entry os.DirEntry) bool {
|
|
return !entry.IsDir() && (strings.HasSuffix(entry.Name(), ".jpg") || strings.HasSuffix(entry.Name(), ".png"))
|
|
}
|
|
|