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 return base::mac::GetUserDirectory(NSApplicationSupportDirectory, result); | 63 // On IOS, this directory does not exist unless it is created explicitly. |
rohitrao (ping after 24h)
2012/07/25 14:45:51
This comment should move down inside the OS_IOS bl
| |
64 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, | |
65 result); | |
66 #if defined(OS_IOS) | |
67 if (success && !file_util::PathExists(*result)) | |
68 success = file_util::CreateDirectory(*result); | |
69 #endif // defined(OS_IOS) | |
70 return success; | |
71 } | |
64 case base::DIR_SOURCE_ROOT: { | 72 case base::DIR_SOURCE_ROOT: { |
65 // Go through PathService to catch overrides. | 73 // Go through PathService to catch overrides. |
66 if (!PathService::Get(base::FILE_EXE, result)) | 74 if (!PathService::Get(base::FILE_EXE, result)) |
67 return false; | 75 return false; |
68 | 76 |
69 // Start with the executable's directory. | 77 // Start with the executable's directory. |
70 *result = result->DirName(); | 78 *result = result->DirName(); |
71 | 79 |
72 #if !defined(OS_IOS) | 80 #if !defined(OS_IOS) |
73 if (base::mac::AmIBundled()) { | 81 if (base::mac::AmIBundled()) { |
74 // The bundled app executables (Chromium, TestShell, etc) live five | 82 // The bundled app executables (Chromium, TestShell, etc) live five |
75 // levels down, eg: | 83 // levels down, eg: |
76 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 84 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
77 *result = result->DirName().DirName().DirName().DirName().DirName(); | 85 *result = result->DirName().DirName().DirName().DirName().DirName(); |
78 } else { | 86 } else { |
79 // Unit tests execute two levels deep from the source root, eg: | 87 // Unit tests execute two levels deep from the source root, eg: |
80 // src/xcodebuild/{Debug|Release}/base_unittests | 88 // src/xcodebuild/{Debug|Release}/base_unittests |
81 *result = result->DirName().DirName(); | 89 *result = result->DirName().DirName(); |
82 } | 90 } |
83 #endif | 91 #endif |
84 return true; | 92 return true; |
85 } | 93 } |
86 default: | 94 default: |
87 return false; | 95 return false; |
88 } | 96 } |
89 } | 97 } |
90 | 98 |
91 } // namespace base | 99 } // namespace base |
OLD | NEW |