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/base_paths_mac.h" | 5 // Defines base::PathProviderMac which replaces base::PathProviderPosix for |
6 // OS_MAXOSX in base/path_service.cc. | |
grt (UTC plus 2)
2012/09/19 16:44:46
"OS_MAXOSX" -> "Mac" for consistency with base_pat
gab
2012/09/19 18:22:58
Done.
| |
6 | 7 |
7 #include <dlfcn.h> | 8 #include <dlfcn.h> |
8 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
9 #include <mach-o/dyld.h> | 10 #include <mach-o/dyld.h> |
10 | 11 |
12 #include "base/base_paths.h" | |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
12 #include "base/file_path.h" | 14 #include "base/file_path.h" |
13 #include "base/file_util.h" | 15 #include "base/file_util.h" |
14 #include "base/logging.h" | 16 #include "base/logging.h" |
15 #include "base/mac/foundation_util.h" | 17 #include "base/mac/foundation_util.h" |
16 #include "base/path_service.h" | 18 #include "base/path_service.h" |
17 #include "base/string_util.h" | 19 #include "base/string_util.h" |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
(...skipping 23 matching lines...) Expand all Loading... | |
44 *path = FilePath(info.dli_fname); | 46 *path = FilePath(info.dli_fname); |
45 return true; | 47 return true; |
46 } | 48 } |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 namespace base { | 52 namespace base { |
51 | 53 |
52 bool PathProviderMac(int key, FilePath* result) { | 54 bool PathProviderMac(int key, FilePath* result) { |
53 switch (key) { | 55 switch (key) { |
54 case base::FILE_EXE: | 56 case base::FILE_EXE: { |
grt (UTC plus 2)
2012/09/19 16:44:46
i think it's more consistent with Chromium style t
gab
2012/09/19 18:22:58
Ok removed it for all but the two big ones (with #
grt (UTC plus 2)
2012/09/19 19:12:06
i don't understand this logic; handling goes until
gab
2012/09/19 19:44:25
You're right, better to go by the simple rule, don
| |
55 GetNSExecutablePath(result); | 57 GetNSExecutablePath(result); |
56 return true; | 58 return true; |
57 case base::FILE_MODULE: | 59 } |
60 case base::FILE_MODULE: { | |
58 return GetModulePathForAddress(result, | 61 return GetModulePathForAddress(result, |
59 reinterpret_cast<const void*>(&base::PathProviderMac)); | 62 reinterpret_cast<const void*>(&base::PathProviderMac)); |
60 case base::DIR_CACHE: | 63 } |
61 return base::mac::GetUserDirectory(NSCachesDirectory, result); | |
62 case base::DIR_APP_DATA: { | 64 case base::DIR_APP_DATA: { |
63 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, | 65 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, |
64 result); | 66 result); |
65 #if defined(OS_IOS) | 67 #if defined(OS_IOS) |
66 // On IOS, this directory does not exist unless it is created explicitly. | 68 // On IOS, this directory does not exist unless it is created explicitly. |
67 if (success && !file_util::PathExists(*result)) | 69 if (success && !file_util::PathExists(*result)) |
68 success = file_util::CreateDirectory(*result); | 70 success = file_util::CreateDirectory(*result); |
69 #endif // defined(OS_IOS) | 71 #endif // defined(OS_IOS) |
70 return success; | 72 return success; |
71 } | 73 } |
(...skipping 12 matching lines...) Expand all Loading... | |
84 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 86 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
85 *result = result->DirName().DirName().DirName().DirName().DirName(); | 87 *result = result->DirName().DirName().DirName().DirName().DirName(); |
86 } else { | 88 } else { |
87 // Unit tests execute two levels deep from the source root, eg: | 89 // Unit tests execute two levels deep from the source root, eg: |
88 // src/xcodebuild/{Debug|Release}/base_unittests | 90 // src/xcodebuild/{Debug|Release}/base_unittests |
89 *result = result->DirName().DirName(); | 91 *result = result->DirName().DirName(); |
90 } | 92 } |
91 #endif | 93 #endif |
92 return true; | 94 return true; |
93 } | 95 } |
96 case base::DIR_USER_DESKTOP: { | |
97 return base::mac::GetUserDirectory(NSDesktopDirectory, result); | |
98 } | |
99 case base::DIR_CACHE: { | |
100 return base::mac::GetUserDirectory(NSCachesDirectory, result); | |
101 } | |
94 case base::DIR_HOME: { | 102 case base::DIR_HOME: { |
95 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); | 103 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); |
96 return true; | 104 return true; |
97 } | 105 } |
98 default: | 106 default: |
99 return false; | 107 return false; |
100 } | 108 } |
101 } | 109 } |
102 | 110 |
103 } // namespace base | 111 } // namespace base |
OLD | NEW |