1
0
Fork 0
mirror of https://github.com/Luzifer/sii.git synced 2024-12-21 00:21:15 +00:00
sii/cmd/sii-editor/paths.go
Knut Ahlers ab39609f45
Implement Save-Game Editor (#1)
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2019-12-28 13:06:28 +00:00

49 lines
1,021 B
Go

package main
import (
"path"
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
const (
pathETS2 = "ets2"
pathATS = "ats"
)
var errPathNotFound = errors.New("Could not find path")
func expandHomedir(dir string) string {
s, err := homedir.Expand(dir)
if err != nil {
log.WithError(err).Error("Unable to expand home path")
return dir
}
return s
}
func getGamePath() string {
return expandHomedir(userConfig.GameDirectories[cfg.Game])
}
func getProfilesPath() string {
return expandHomedir(userConfig.ProfileDirectories[cfg.Game])
}
func getProfilePath(profile string) string {
return path.Join(getProfilesPath(), profile)
}
func getProfileInfoPath(profile string) string {
return path.Join(getProfilePath(profile), "profile.sii")
}
func getSavePath(profile, save string) string {
return path.Join(getProfilePath(profile), "save", save)
}
func getSaveFilePath(profile, save, file string) string {
return path.Join(getSavePath(profile, save), file)
}