summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Path.cpp
diff options
context:
space:
mode:
authorPawel Bylica <chfast@gmail.com>2015-11-02 09:49:17 +0000
committerPawel Bylica <chfast@gmail.com>2015-11-02 09:49:17 +0000
commit0e97e5cb1907ef55966fd27055698515e522c0f0 (patch)
tree96385d621315224f0adcac2af1413d7e64d7bb23 /llvm/lib/Support/Path.cpp
parent8671c6e03dc6a1e10d41ad825075cb912b05c570 (diff)
downloadbcm5719-llvm-0e97e5cb1907ef55966fd27055698515e522c0f0.tar.gz
bcm5719-llvm-0e97e5cb1907ef55966fd27055698515e522c0f0.zip
[Support] Extend sys::path with user_cache_directory function.
Summary: The new function sys::path::user_cache_directory tries to discover a directory suitable for cache storage for current system user. On Windows and Darwin it returns a path to system-specific user cache directory. On Linux it follows XDG Base Directory Specification, what is: - use non-empty $XDG_CACHE_HOME env var, - use $HOME/.cache. Reviewers: chapuni, aaron.ballman, rafael Subscribers: rafael, aaron.ballman, llvm-commits Differential Revision: http://reviews.llvm.org/D13801 llvm-svn: 251784
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r--llvm/lib/Support/Path.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index e5150bcbb7e..f45774bca7b 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -1094,3 +1094,20 @@ std::error_code directory_entry::status(file_status &result) const {
#if defined(LLVM_ON_WIN32)
#include "Windows/Path.inc"
#endif
+
+namespace llvm {
+namespace sys {
+namespace path {
+
+bool user_cache_directory(SmallVectorImpl<char> &Result, const Twine &Path1,
+ const Twine &Path2, const Twine &Path3) {
+ if (getUserCacheDir(Result)) {
+ append(Result, Path1, Path2, Path3);
+ return true;
+ }
+ return false;
+}
+
+} // end namespace path
+} // end namsspace sys
+} // end namespace llvm
OpenPOWER on IntegriCloud