This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/paths/paths.go

35 lines
799 B
Go

package paths
import (
"os"
"strings"
)
// ExpandHome replaces a leading "~" or "~/" with the user's home directory.
func ExpandHome(path string) string {
if path == "~" || strings.HasPrefix(path, "~/") {
if home, _ := os.UserHomeDir(); home != "" {
return home + path[1:]
}
}
return path
}
// CfgDir returns the ollie config root from OLLIE_CFG_PATH, defaulting to ~/.config/ollie.
func CfgDir() string {
if p := os.Getenv("OLLIE_CFG_PATH"); p != "" {
return p
}
home, _ := os.UserHomeDir()
return home + "/.config/ollie"
}
// DataDir returns the ollie data root from OLLIE_DATA_PATH, defaulting to ~/.local/share/ollie.
func DataDir() string {
if p := os.Getenv("OLLIE_DATA_PATH"); p != "" {
return p
}
home, _ := os.UserHomeDir()
return home + "/.local/share/ollie"
}