2020-11-03 12:54:15 +00:00
|
|
|
package d2config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2021-03-24 03:18:19 +00:00
|
|
|
"path/filepath"
|
2020-11-03 12:54:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-03-24 03:02:41 +00:00
|
|
|
od2ConfigDirName = "OpenDiablo2"
|
2020-11-03 12:54:15 +00:00
|
|
|
od2ConfigFileName = "config.json"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DefaultConfigPath returns the absolute path for the default config file location
|
|
|
|
func DefaultConfigPath() string {
|
|
|
|
if configDir, err := os.UserConfigDir(); err == nil {
|
2021-03-24 03:18:19 +00:00
|
|
|
return filepath.Join(configDir, od2ConfigDirName, od2ConfigFileName)
|
2020-11-03 12:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return LocalConfigPath()
|
|
|
|
}
|
|
|
|
|
|
|
|
// LocalConfigPath returns the absolute path to the directory of the OpenDiablo2 executable
|
|
|
|
func LocalConfigPath() string {
|
2021-03-24 03:18:19 +00:00
|
|
|
return filepath.Join(filepath.Dir(os.Args[0]), od2ConfigFileName)
|
2020-11-03 12:54:15 +00:00
|
|
|
}
|