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

Unified Diff: base/file_util_mac.mm

Issue 159833003: Add support for GetHomeDir for Mac and Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android compile 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_mac.mm
diff --git a/base/file_util_mac.mm b/base/file_util_mac.mm
index 7a994267c1ddddeaec2dfc15f7530396c974bbc6..af8228428eee7a72e584a10632a6278e4e582a1f 100644
--- a/base/file_util_mac.mm
+++ b/base/file_util_mac.mm
@@ -32,6 +32,27 @@ bool GetTempDir(base::FilePath* path) {
return true;
}
+FilePath GetHomeDir() {
benwells 2014/02/16 23:39:50 You should also remove the handling for base::DIR_
brettw 2014/02/18 19:24:42 Good catch.
+ const char* home_dir = getenv("HOME");
benwells 2014/02/16 23:39:50 I don't know much about mac. Is the change to prio
brettw 2014/02/18 19:24:42 I just copied the Linux behavior, but a Mac person
+ if (home_dir && home_dir[0])
+ return FilePath(home_dir);
+
+ NSString* tmp = NSHomeDirectory();
+ if (tmp != nil) {
+ FilePath mac_home_dir = base::mac::NSStringToFilePath(NSHomeDirectory());
+ if (!mac_home_dir.empty())
+ return mac_home_dir;
+ }
+
+ // Fall back on temp dir if no home directory is defined.
+ FilePath rv;
+ if (GetTempDir(&rv))
+ return rv;
+
+ // Last resort.
+ return FilePath("/tmp");
+}
+
bool GetShmemTempDir(bool executable, base::FilePath* path) {
return GetTempDir(path);
}
« base/base_paths.cc ('K') | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698