mirror of
https://github.com/Luzifer/sii.git
synced 2024-12-21 08:21:16 +00:00
49 lines
1,021 B
Go
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)
|
|
}
|