summaryrefslogtreecommitdiff
path: root/makeFilenames.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-20 13:20:40 -0500
committerJeff Carr <[email protected]>2025-10-20 13:20:40 -0500
commit5c4c1fcaf4e724573dd39b4d4fa0d600a9870221 (patch)
treec50e35d812e30029a40132c7653504b79a0c3c9b /makeFilenames.go
parentc99d5193053a9377acfb62677bf241e540f9f6ee (diff)
maybe better than before. notsure
Diffstat (limited to 'makeFilenames.go')
-rw-r--r--makeFilenames.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/makeFilenames.go b/makeFilenames.go
new file mode 100644
index 0000000..6ade093
--- /dev/null
+++ b/makeFilenames.go
@@ -0,0 +1,31 @@
+package config
+
+// config files are always human readable (foo.text)
+// cache files are always raw data (foo.pb)
+
+import (
+ "os"
+ "path/filepath"
+)
+
+// ~/.config/appname/protoname.text
+func makeConfigFilename(appname string, protoname string) string {
+ var err error
+ configDir, err := os.UserConfigDir()
+ if err != nil {
+ // todo: get something better than /tmp/ if anyone cares
+ return filepath.Join("/tmp", appname, protoname+".text")
+ }
+ return filepath.Join(configDir, appname, protoname+".text")
+}
+
+// ~/.cache/appname/protoname.pb
+func makeCacheFilename(appname string, protoname string) string {
+ var err error
+ cacheDir, err := os.UserCacheDir()
+ if err != nil {
+ // todo: get something better than /tmp/ if anyone cares
+ return filepath.Join("/tmp", appname, protoname+".pb")
+ }
+ return filepath.Join(cacheDir, appname, protoname+".pb")
+}