X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FSupport%2FWindows%2FPath.inc;h=e218fa2e726e69ba2001522ec76a34749421e75b;hb=bef2236283c333f17613b2ea4904878228fedb6e;hp=4ef7285801a6357fc99c23a086508e364caee256;hpb=f10743d765c456db7c9cd2a9fe4c528d75bb5b8f;p=oota-llvm.git diff --git a/lib/Support/Windows/Path.inc b/lib/Support/Windows/Path.inc index 4ef7285801a..e218fa2e726 100644 --- a/lib/Support/Windows/Path.inc +++ b/lib/Support/Windows/Path.inc @@ -19,6 +19,7 @@ #include "llvm/ADT/STLExtras.h" #include #include +#include #include #include @@ -1063,6 +1064,22 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD, } } // end namespace fs +namespace path { + +bool home_directory(SmallVectorImpl &result) { + wchar_t Path[MAX_PATH]; + if (::SHGetFolderPathW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, 0, + SHGFP_TYPE_CURRENT, Path) != S_OK) + return false; + + if (UTF16ToUTF8(Path, ::wcslen(Path), result)) + return false; + + return true; +} + +} // end namespace path + namespace windows { llvm::error_code UTF8ToUTF16(llvm::StringRef utf8, llvm::SmallVectorImpl &utf16) {