[llvm-commits] [llvm] r118506 - /llvm/trunk/lib/System/Win32/Path.inc

Michael J. Spencer bigcheesegs at gmail.com
Tue Nov 9 07:11:31 PST 2010


Author: mspencer
Date: Tue Nov  9 09:11:31 2010
New Revision: 118506

URL: http://llvm.org/viewvc/llvm-project?rev=118506&view=rev
Log:
System/Path/Windows: Generalize GetUserHomeDirectory.

Modified:
    llvm/trunk/lib/System/Win32/Path.inc

Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=118506&r1=118505&r2=118506&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Tue Nov  9 09:11:31 2010
@@ -293,14 +293,15 @@
 
 Path
 Path::GetUserHomeDirectory() {
-  // TODO: Typical Windows setup doesn't define HOME.
-  const char* home = getenv("HOME");
-  if (home) {
-    Path result;
-    if (result.set(home))
-      return result;
-  }
-  return GetRootDirectory();
+  char buff[MAX_PATH];
+  HRESULT res =  SHGetFolderPathA(NULL,
+                                  CSIDL_FLAG_CREATE | CSIDL_APPDATA,
+                                  NULL,
+                                  SHGFP_TYPE_CURRENT,
+                                  buff);
+  if (res != S_OK)
+    assert(0 && "Failed to get user home directory");
+  return Path(buff);
 }
 
 Path





More information about the llvm-commits mailing list