36 lines
587 B
Go
36 lines
587 B
Go
package internal
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
const (
|
|
AppName = "hxclaw"
|
|
ConfigDirName = ".config"
|
|
)
|
|
|
|
func GetUserHome() string {
|
|
home := os.Getenv("HOME")
|
|
if home == "" {
|
|
home = os.Getenv("USERPROFILE")
|
|
}
|
|
return home
|
|
}
|
|
|
|
func GetConfigDir() string {
|
|
return filepath.Join(GetUserHome(), ConfigDirName, AppName)
|
|
}
|
|
|
|
func GetConfigFile() string {
|
|
return filepath.Join(GetConfigDir(), "config.yml")
|
|
}
|
|
|
|
func GetDBFile() string {
|
|
return filepath.Join(GetConfigDir(), "hxclaw.db")
|
|
}
|
|
|
|
func EnsureConfigDir() error {
|
|
dir := GetConfigDir()
|
|
return os.MkdirAll(dir, 0755)
|
|
} |