From f7d4101156fd3f5c034edde12adb1eabde07cef5 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 31 Jan 2014 23:46:06 +0000 Subject: 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 --- llvm/lib/Support/Unix/Path.inc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'llvm/lib/Support/Unix/Path.inc') 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 &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 -- cgit v1.2.3