Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: base/file_util_win.cc

Issue 159833003: Add support for GetHomeDir for Mac and Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index b2f69c85ae1d81db757646b16828984d08d8aaef..d42ffac1f032ad6a844bfa5e87412d2d1628091f 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -258,6 +258,22 @@ bool GetShmemTempDir(bool executable, FilePath* path) {
return GetTempDir(path);
}
+FilePath GetHomeDir() {
+ char16 result[MAX_PATH];
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT,
+ result)) &&
+ result[0])
+ return FilePath(result);
benwells 2014/02/18 23:14:40 Nit: curlies around block as if spans multiple lin
+
+ // Fall back to the temporary directory on failure.
+ FilePath temp;
+ if (GetTempDir(&temp))
+ return temp;
+
+ // Last resort.
+ return FilePath(L"C:\\");
+}
+
bool CreateTemporaryFile(FilePath* path) {
ThreadRestrictions::AssertIOAllowed();

Powered by Google App Engine
This is Rietveld 408576698