| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return true; | 64 return true; |
| 65 case base::FILE_MODULE: | 65 case base::FILE_MODULE: |
| 66 return GetModulePathForAddress(result, | 66 return GetModulePathForAddress(result, |
| 67 reinterpret_cast<const void*>(&base::PathProviderMac)); | 67 reinterpret_cast<const void*>(&base::PathProviderMac)); |
| 68 case base::DIR_APP_DATA: { | 68 case base::DIR_APP_DATA: { |
| 69 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, | 69 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, |
| 70 result); | 70 result); |
| 71 #if defined(OS_IOS) | 71 #if defined(OS_IOS) |
| 72 // On IOS, this directory does not exist unless it is created explicitly. | 72 // On IOS, this directory does not exist unless it is created explicitly. |
| 73 if (success && !base::PathExists(*result)) | 73 if (success && !base::PathExists(*result)) |
| 74 success = file_util::CreateDirectory(*result); | 74 success = base::CreateDirectory(*result); |
| 75 #endif // defined(OS_IOS) | 75 #endif // defined(OS_IOS) |
| 76 return success; | 76 return success; |
| 77 } | 77 } |
| 78 case base::DIR_SOURCE_ROOT: | 78 case base::DIR_SOURCE_ROOT: |
| 79 // Go through PathService to catch overrides. | 79 // Go through PathService to catch overrides. |
| 80 if (!PathService::Get(base::FILE_EXE, result)) | 80 if (!PathService::Get(base::FILE_EXE, result)) |
| 81 return false; | 81 return false; |
| 82 | 82 |
| 83 // Start with the executable's directory. | 83 // Start with the executable's directory. |
| 84 *result = result->DirName(); | 84 *result = result->DirName(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 108 return base::mac::GetUserDirectory(NSCachesDirectory, result); | 108 return base::mac::GetUserDirectory(NSCachesDirectory, result); |
| 109 case base::DIR_HOME: | 109 case base::DIR_HOME: |
| 110 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); | 110 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); |
| 111 return true; | 111 return true; |
| 112 default: | 112 default: |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace base | 117 } // namespace base |
| OLD | NEW |