summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2014-01-31 23:46:06 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2014-01-31 23:46:06 +0000
commitf7d4101156fd3f5c034edde12adb1eabde07cef5 (patch)
tree60588c0ce040d7da898098d0a53f502487b63bda /llvm/lib/Support/Unix
parentdfbed59cc26a0918d5bf1dade19f6c95b64581e0 (diff)
downloadbcm5719-llvm-f7d4101156fd3f5c034edde12adb1eabde07cef5.tar.gz
bcm5719-llvm-f7d4101156fd3f5c034edde12adb1eabde07cef5.zip
Introduce llvm::sys::path::home_directory.
This will be used by the line editor library to derive a default path to the history file. Differential Revision: http://llvm-reviews.chandlerc.com/D2199 llvm-svn: 200594
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r--llvm/lib/Support/Unix/Path.inc15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index d5260424616..d0b63b5ba5c 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -797,5 +797,20 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD,
}
} // end namespace fs
+
+namespace path {
+
+bool home_directory(SmallVectorImpl<char> &result) {
+ if (char *RequestedDir = getenv("HOME")) {
+ result.clear();
+ result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
+ return true;
+ }
+
+ return false;
+}
+
+} // end namespace path
+
} // end namespace sys
} // end namespace llvm
OpenPOWER on IntegriCloud