summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows
diff options
context:
space:
mode:
authorPawel Bylica <chfast@gmail.com>2015-10-16 09:08:59 +0000
committerPawel Bylica <chfast@gmail.com>2015-10-16 09:08:59 +0000
commit7187e4bba90943c86e3569519b997c1d6f40c72f (patch)
tree75158fd7e584674ab7b7c0055eff2f6b4b5725a9 /llvm/lib/Support/Windows
parent3f072ef82c705a67dd5c91051acf08e698767e95 (diff)
downloadbcm5719-llvm-7187e4bba90943c86e3569519b997c1d6f40c72f.tar.gz
bcm5719-llvm-7187e4bba90943c86e3569519b997c1d6f40c72f.zip
Use Windows Vista API to get the user's home directory
Summary: This patch replaces usage of deprecated SHGetFolderPathW with SHGetKnownFolderPath. The usage of SHGetKnownFolderPath is wrapped to allow queries for other "known" folders in the near future. Reviewers: aaron.ballman, gbedwell Subscribers: chapuni, llvm-commits Differential Revision: http://reviews.llvm.org/D13753 llvm-svn: 250501
Diffstat (limited to 'llvm/lib/Support/Windows')
-rw-r--r--llvm/lib/Support/Windows/Path.inc18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index 2c111321c60..839beebfcb6 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -753,16 +753,20 @@ std::error_code openFileForWrite(const Twine &Name, int &ResultFD,
namespace path {
-bool home_directory(SmallVectorImpl<char> &result) {
- wchar_t Path[MAX_PATH];
- if (::SHGetFolderPathW(0, CSIDL_APPDATA | CSIDL_FLAG_CREATE, 0,
- /*SHGFP_TYPE_CURRENT*/0, Path) != S_OK)
+namespace {
+bool getKnownFolderPath(KNOWNFOLDERID folderId, SmallVectorImpl<char> &result) {
+ wchar_t *path = nullptr;
+ if (::SHGetKnownFolderPath(folderId, KF_FLAG_CREATE, nullptr, &path) != S_OK)
return false;
- if (UTF16ToUTF8(Path, ::wcslen(Path), result))
- return false;
+ bool ok = !UTF16ToUTF8(path, ::wcslen(path), result);
+ ::CoTaskMemFree(path);
+ return ok;
+}
+}
- return true;
+bool home_directory(SmallVectorImpl<char> &result) {
+ return getKnownFolderPath(FOLDERID_Profile, result);
}
static bool getTempDirEnvVar(const char *Var, SmallVectorImpl<char> &Res) {
OpenPOWER on IntegriCloud