summaryrefslogtreecommitdiff
path: root/paths/paths.go
diff options
context:
space:
mode:
Diffstat (limited to 'paths/paths.go')
-rw-r--r--paths/paths.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/paths/paths.go b/paths/paths.go
new file mode 100644
index 0000000..0445658
--- /dev/null
+++ b/paths/paths.go
@@ -0,0 +1,31 @@
+package paths
+
+import (
+ "github.com/adrg/xdg"
+ "os"
+ "path/filepath"
+ "pik/spool"
+ "strings"
+)
+
+var (
+ Home = xdg.Home
+ This = "pik"
+ Cache = filepath.Join(xdg.CacheHome, This)
+ Config = filepath.Join(xdg.ConfigHome, This)
+)
+
+func init() {
+ err := os.MkdirAll(Cache, 0700)
+ if err != nil {
+ spool.Warn("%v\n", err)
+ }
+ err = os.MkdirAll(Config, 0700)
+ if err != nil {
+ spool.Warn("%v\n", err)
+ }
+}
+
+func ReplaceHome(input string) string {
+ return strings.Replace(input, Home, "~", 1)
+}