OLD | NEW |
---|---|
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 Loading... | |
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() { | |
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.
| |
36 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
| |
37 if (home_dir && home_dir[0]) | |
38 return FilePath(home_dir); | |
39 | |
40 NSString* tmp = NSHomeDirectory(); | |
41 if (tmp != nil) { | |
42 FilePath mac_home_dir = base::mac::NSStringToFilePath(NSHomeDirectory()); | |
43 if (!mac_home_dir.empty()) | |
44 return mac_home_dir; | |
45 } | |
46 | |
47 // Fall back on temp dir if no home directory is defined. | |
48 FilePath rv; | |
49 if (GetTempDir(&rv)) | |
50 return rv; | |
51 | |
52 // Last resort. | |
53 return FilePath("/tmp"); | |
54 } | |
55 | |
35 bool GetShmemTempDir(bool executable, base::FilePath* path) { | 56 bool GetShmemTempDir(bool executable, base::FilePath* path) { |
36 return GetTempDir(path); | 57 return GetTempDir(path); |
37 } | 58 } |
38 | 59 |
39 } // namespace base | 60 } // namespace base |
OLD | NEW |