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 #include "base/base_paths_mac.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
9 #include <mach-o/dyld.h> | 9 #include <mach-o/dyld.h> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 bool PathProviderMac(int key, FilePath* result) { | 52 bool PathProviderMac(int key, FilePath* result) { |
53 switch (key) { | 53 switch (key) { |
54 case base::FILE_EXE: | 54 case base::FILE_EXE: |
55 GetNSExecutablePath(result); | 55 GetNSExecutablePath(result); |
56 return true; | 56 return true; |
57 case base::FILE_MODULE: | 57 case base::FILE_MODULE: |
58 return GetModulePathForAddress(result, | 58 return GetModulePathForAddress(result, |
59 reinterpret_cast<const void*>(&base::PathProviderMac)); | 59 reinterpret_cast<const void*>(&base::PathProviderMac)); |
60 case base::DIR_CACHE: | 60 case base::DIR_CACHE: |
61 return base::mac::GetUserDirectory(NSCachesDirectory, result); | 61 return base::mac::GetUserDirectory(NSCachesDirectory, result); |
62 case base::DIR_APP_DATA: | 62 case base::DIR_APP_DATA: { |
63 #if defined(OS_IOS) | |
rohitrao (ping after 24h)
2012/07/18 16:01:34
bool success = base::mac::GetUserDirectory(NSAppli
chenyu
2012/07/18 16:43:32
Done. I keep the if-def for now and will remove it
| |
64 // On IOS, this directory does not exist unless it is created explicitly. | |
65 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, | |
66 result); | |
67 if (success && !file_util::PathExists(*result) && | |
68 !file_util::CreateDirectory(*result)) { | |
69 return false; | |
70 } | |
71 return success; | |
72 #else | |
63 return base::mac::GetUserDirectory(NSApplicationSupportDirectory, result); | 73 return base::mac::GetUserDirectory(NSApplicationSupportDirectory, result); |
74 #endif // defined(OS_IOS) | |
75 } | |
64 case base::DIR_SOURCE_ROOT: { | 76 case base::DIR_SOURCE_ROOT: { |
65 // Go through PathService to catch overrides. | 77 // Go through PathService to catch overrides. |
66 if (!PathService::Get(base::FILE_EXE, result)) | 78 if (!PathService::Get(base::FILE_EXE, result)) |
67 return false; | 79 return false; |
68 | 80 |
69 // Start with the executable's directory. | 81 // Start with the executable's directory. |
70 *result = result->DirName(); | 82 *result = result->DirName(); |
71 | 83 |
72 #if !defined(OS_IOS) | 84 #if !defined(OS_IOS) |
73 if (base::mac::AmIBundled()) { | 85 if (base::mac::AmIBundled()) { |
74 // The bundled app executables (Chromium, TestShell, etc) live five | 86 // The bundled app executables (Chromium, TestShell, etc) live five |
75 // levels down, eg: | 87 // levels down, eg: |
76 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 88 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
77 *result = result->DirName().DirName().DirName().DirName().DirName(); | 89 *result = result->DirName().DirName().DirName().DirName().DirName(); |
78 } else { | 90 } else { |
79 // Unit tests execute two levels deep from the source root, eg: | 91 // Unit tests execute two levels deep from the source root, eg: |
80 // src/xcodebuild/{Debug|Release}/base_unittests | 92 // src/xcodebuild/{Debug|Release}/base_unittests |
81 *result = result->DirName().DirName(); | 93 *result = result->DirName().DirName(); |
82 } | 94 } |
83 #endif | 95 #endif |
84 return true; | 96 return true; |
85 } | 97 } |
86 default: | 98 default: |
87 return false; | 99 return false; |
88 } | 100 } |
89 } | 101 } |
90 | 102 |
91 } // namespace base | 103 } // namespace base |
OLD | NEW |