summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--paths/paths.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/paths/paths.go b/paths/paths.go
index 80928df..9f27385 100644
--- a/paths/paths.go
+++ b/paths/paths.go
@@ -7,20 +7,30 @@ import (
"strings"
)
-var (
- Home = xdg.Home
- This = "pik"
- Cache = filepath.Join(xdg.CacheHome, This)
- Config = filepath.Join(xdg.ConfigHome, This)
- Ifs = os.Getenv("IFS")
-)
+var Home, This, Cache, Config, Ifs string
type paths struct {
+ Initialized bool
+}
+
+var Paths = &paths{
+ Initialized: false,
}
-var Paths = &paths{}
+func (p *paths) Init() error {
+
+ // if we're asked to initialize for a second time,
+ // probably some environment has changed
+ if p.Initialized {
+ xdg.Reload()
+ }
+
+ Home = xdg.Home
+ This = "pik"
+ Cache = filepath.Join(xdg.CacheHome, This)
+ Config = filepath.Join(xdg.ConfigHome, This)
+ Ifs = os.Getenv("IFS")
-func (p paths) Init() error {
err := os.MkdirAll(Cache, 0700)
if err != nil {
return err
@@ -32,6 +42,7 @@ func (p paths) Init() error {
if Ifs == "" {
Ifs = "\n"
}
+ p.Initialized = true
return nil
}