aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-03-18 22:23:16 -0400
committerPaul Duncan <pabs@pablotron.org>2022-03-18 22:23:16 -0400
commita06e3362be691331215b10bdefc28a2db363563a (patch)
treea9f7379bc00982c7572f9732fc13e0fa29460183
parent4cc13f2fde11241919d3699574c30b2590060833 (diff)
downloadcvez-a06e3362be691331215b10bdefc28a2db363563a.tar.bz2
cvez-a06e3362be691331215b10bdefc28a2db363563a.zip
datadir/datadir.go: add CacheDir()
-rw-r--r--datadir/datadir.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/datadir/datadir.go b/datadir/datadir.go
index 9019e5d..583dac4 100644
--- a/datadir/datadir.go
+++ b/datadir/datadir.go
@@ -46,3 +46,16 @@ func Join(args ...string) (string, error) {
return filepath.Join(dir, filepath.Join(args...)), nil
}
}
+
+// Get path to cache directory path within data directory and create it
+// if it does not exist.
+func CacheDir() (string, error) {
+ // build path, check for error
+ dir, err := Join("cache")
+ if err != nil {
+ return "", err
+ }
+
+ // create and return cache directory
+ return dir, os.MkdirAll(dir, 0700)
+}