about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-20T12·12+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-20T12·12+0200
commit451ebf24ce532f8d59f929efd486104fcebf1aa6 (patch)
tree08bf43e0aad39626a1cc1ab9d5e638fdf90567b9 /src/libutil/util.cc
parente0204f8d462041387651af388074491fd0bf36d6 (diff)
Cache path info lookups in SQLite
This re-implements the binary cache database in C++, allowing it to be
used by other Store backends, in particular the S3 backend.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 55d490992108..8ffa6973ddc2 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -403,6 +403,18 @@ Path createTempDir(const Path & tmpRoot, const Path & prefix,
 }
 
 
+Path getCacheDir()
+{
+    Path cacheDir = getEnv("XDG_CACHE_HOME");
+    if (cacheDir.empty()) {
+        Path homeDir = getEnv("HOME");
+        if (homeDir.empty()) throw Error("$XDG_CACHE_HOME and $HOME are not set");
+        cacheDir = homeDir + "/.cache";
+    }
+    return cacheDir;
+}
+
+
 Paths createDirs(const Path & path)
 {
     Paths created;