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 // Defines base::PathProviderMac which replaces base::PathProviderPosix for Mac | 5 // Defines base::PathProviderMac which replaces base::PathProviderPosix for Mac |
6 // in base/path_service.cc. | 6 // in base/path_service.cc. |
7 | 7 |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 #include <mach-o/dyld.h> | 10 #include <mach-o/dyld.h> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 GetNSExecutablePath(result); | 58 GetNSExecutablePath(result); |
59 return true; | 59 return true; |
60 case base::FILE_MODULE: | 60 case base::FILE_MODULE: |
61 return GetModulePathForAddress(result, | 61 return GetModulePathForAddress(result, |
62 reinterpret_cast<const void*>(&base::PathProviderMac)); | 62 reinterpret_cast<const void*>(&base::PathProviderMac)); |
63 case base::DIR_APP_DATA: { | 63 case base::DIR_APP_DATA: { |
64 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, | 64 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, |
65 result); | 65 result); |
66 #if defined(OS_IOS) | 66 #if defined(OS_IOS) |
67 // On IOS, this directory does not exist unless it is created explicitly. | 67 // On IOS, this directory does not exist unless it is created explicitly. |
68 if (success && !file_util::PathExists(*result)) | 68 if (success && !base::PathExists(*result)) |
69 success = file_util::CreateDirectory(*result); | 69 success = file_util::CreateDirectory(*result); |
70 #endif // defined(OS_IOS) | 70 #endif // defined(OS_IOS) |
71 return success; | 71 return success; |
72 } | 72 } |
73 case base::DIR_SOURCE_ROOT: | 73 case base::DIR_SOURCE_ROOT: |
74 // Go through PathService to catch overrides. | 74 // Go through PathService to catch overrides. |
75 if (!PathService::Get(base::FILE_EXE, result)) | 75 if (!PathService::Get(base::FILE_EXE, result)) |
76 return false; | 76 return false; |
77 | 77 |
78 // Start with the executable's directory. | 78 // Start with the executable's directory. |
(...skipping 24 matching lines...) Expand all Loading... |
103 return base::mac::GetUserDirectory(NSCachesDirectory, result); | 103 return base::mac::GetUserDirectory(NSCachesDirectory, result); |
104 case base::DIR_HOME: | 104 case base::DIR_HOME: |
105 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); | 105 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); |
106 return true; | 106 return true; |
107 default: | 107 default: |
108 return false; | 108 return false; |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 } // namespace base | 112 } // namespace base |
OLD | NEW |