mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
47 lines
991 B
Go
47 lines
991 B
Go
package core
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
func GetPackwizLocalStore() (string, error) {
|
|
if //goland:noinspection GoBoolExpressions
|
|
runtime.GOOS == "linux" {
|
|
// Prefer $XDG_DATA_HOME over $XDG_CACHE_HOME
|
|
dataHome := os.Getenv("XDG_DATA_HOME")
|
|
if dataHome != "" {
|
|
return filepath.Join(dataHome, "packwiz"), nil
|
|
}
|
|
}
|
|
userConfigDir, err := os.UserConfigDir()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(userConfigDir, "packwiz"), nil
|
|
}
|
|
|
|
func GetPackwizInstallBinPath() (string, error) {
|
|
localStore, err := GetPackwizLocalStore()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return filepath.Join(localStore, "bin"), nil
|
|
}
|
|
|
|
func GetPackwizInstallBinFile() (string, error) {
|
|
binPath, err := GetPackwizInstallBinPath()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
var exeName string
|
|
if //goland:noinspection GoBoolExpressions
|
|
runtime.GOOS == "windows" {
|
|
exeName = "packwiz.exe"
|
|
} else {
|
|
exeName = "packwiz"
|
|
}
|
|
return filepath.Join(binPath, exeName), nil
|
|
}
|