mirror of
https://github.com/chenasraf/stimvisor.git
synced 2026-05-17 17:38:11 +00:00
feat: use proper config/cache dir
This commit is contained in:
@@ -3,12 +3,33 @@ package common
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func GetConfigDir() string {
|
||||
if os.Getenv("XDG_CONFIG_HOME") != "" {
|
||||
return filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "stimvisor")
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
return filepath.Join(os.Getenv("APPDATA"), "stimvisor")
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return filepath.Join(home, ".stimvisor")
|
||||
return filepath.Join(home, ".config", "stimvisor")
|
||||
}
|
||||
|
||||
func GetCacheDir() string {
|
||||
if os.Getenv("XDG_CACHE_HOME") != "" {
|
||||
return filepath.Join(os.Getenv("XDG_CACHE_HOME"), "stimvisor")
|
||||
}
|
||||
if runtime.GOOS == "windows" {
|
||||
return filepath.Join(os.Getenv("LOCALAPPDATA"), "stimvisor")
|
||||
}
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return filepath.Join(home, ".cache", "stimvisor")
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ func GetGameInfo(gameId string) (GameInfo, error) {
|
||||
|
||||
// GetGameInfoCacheDir returns the directory path for caching game information.
|
||||
func GetGameInfoCacheDir() string {
|
||||
configDir := common.GetConfigDir()
|
||||
return filepath.Join(configDir, "cache", "gameinfo")
|
||||
cacheDir := common.GetCacheDir()
|
||||
return filepath.Join(cacheDir, "gameinfo")
|
||||
}
|
||||
|
||||
// loadGameInfo loads the game information from the cache or fetches it if not available.
|
||||
|
||||
Reference in New Issue
Block a user