diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-03-18 22:23:16 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-03-18 22:23:16 -0400 |
commit | a06e3362be691331215b10bdefc28a2db363563a (patch) | |
tree | a9f7379bc00982c7572f9732fc13e0fa29460183 /datadir | |
parent | 4cc13f2fde11241919d3699574c30b2590060833 (diff) | |
download | cvez-a06e3362be691331215b10bdefc28a2db363563a.tar.bz2 cvez-a06e3362be691331215b10bdefc28a2db363563a.zip |
datadir/datadir.go: add CacheDir()
Diffstat (limited to 'datadir')
-rw-r--r-- | datadir/datadir.go | 13 |
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) +} |