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

Side by Side 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: review comments 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/file_util.h" 5 #include "base/file_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <copyfile.h> 8 #include <copyfile.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 14 matching lines...) Expand all
25 } // namespace internal 25 } // namespace internal
26 26
27 bool GetTempDir(base::FilePath* path) { 27 bool GetTempDir(base::FilePath* path) {
28 NSString* tmp = NSTemporaryDirectory(); 28 NSString* tmp = NSTemporaryDirectory();
29 if (tmp == nil) 29 if (tmp == nil)
30 return false; 30 return false;
31 *path = base::mac::NSStringToFilePath(tmp); 31 *path = base::mac::NSStringToFilePath(tmp);
32 return true; 32 return true;
33 } 33 }
34 34
35 FilePath GetHomeDir() {
36 NSString* tmp = NSHomeDirectory();
37 if (tmp != nil) {
38 FilePath mac_home_dir = base::mac::NSStringToFilePath(tmp);
39 if (!mac_home_dir.empty())
40 return mac_home_dir;
41 }
42
43 // Fall back on temp dir if no home directory is defined.
44 FilePath rv;
45 if (GetTempDir(&rv))
46 return rv;
47
48 // Last resort.
49 return FilePath("/tmp");
50 }
51
35 bool GetShmemTempDir(bool executable, base::FilePath* path) { 52 bool GetShmemTempDir(bool executable, base::FilePath* path) {
36 return GetTempDir(path); 53 return GetTempDir(path);
37 } 54 }
38 55
39 } // namespace base 56 } // namespace base
OLDNEW
« no previous file with comments | « 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