images perchance?

This commit is contained in:
Trit0 2025-06-29 18:35:33 -04:00
parent 22e2cc088c
commit b46eefa34a

View File

@ -73,6 +73,7 @@ func GetOrSetEnvKey(key string, defaultValue string) string {
func extractZipToSiblingFolder(zipPath string) error {
// Determine destination folder name (same name as zip file, without .zip)
zipBase := strings.TrimSuffix(filepath.Base(zipPath), ".conj")
zipBase = strings.TrimSuffix(filepath.Base(zipBase), ".zip")
destDir := filepath.Join(filepath.Dir(zipPath), zipBase)
// Delete destination folder if it exists
@ -186,14 +187,14 @@ func GetConjureGameInfo() []models.Game {
newGames := readFolder(e, gamePath)
games = append(newGames, games...)
} else if filepath.Ext(e.Name()) == ".conj" {
zipPath := filepath.Join(gamePath, e.Name())
r, err := zip.OpenReader(zipPath)
conjPath := filepath.Join(gamePath, e.Name())
r, err := zip.OpenReader(conjPath)
if err != nil {
log.Fatal(err)
}
defer r.Close()
fmt.Println("Contents of", zipPath)
fmt.Println("Contents of", conjPath)
for _, f := range r.File {
printIndentedPath(f.Name)
if f.Name == "metadata.txt" {
@ -206,6 +207,9 @@ func GetConjureGameInfo() []models.Game {
fmt.Println("Contents of metadata.txt:")
metadata, err := io.ReadAll(rc)
game := parseGameInfo(metadata)
conjBase := strings.TrimSuffix(filepath.Base(conjPath), ".conj")
game.ThumbnailPath = filepath.Join(conjBase, game.ThumbnailPath)
game.ImagePath = filepath.Join(conjBase, game.ImagePath)
games = append(games, game)
if err != nil {
log.Fatal(err)