| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(HOST_OS_MACOS) | 6 #if defined(HOST_OS_MACOS) |
| 7 | 7 |
| 8 #include "bin/platform.h" | 8 #include "bin/platform.h" |
| 9 | 9 |
| 10 #include <CoreFoundation/CoreFoundation.h> | 10 #include <CoreFoundation/CoreFoundation.h> |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 char** result; | 185 char** result; |
| 186 result = reinterpret_cast<char**>(Dart_ScopeAllocate(i * sizeof(*result))); | 186 result = reinterpret_cast<char**>(Dart_ScopeAllocate(i * sizeof(*result))); |
| 187 for (intptr_t current = 0; current < i; current++) { | 187 for (intptr_t current = 0; current < i; current++) { |
| 188 result[current] = environ[current]; | 188 result[current] = environ[current]; |
| 189 } | 189 } |
| 190 return result; | 190 return result; |
| 191 #endif | 191 #endif |
| 192 } | 192 } |
| 193 | 193 |
| 194 | 194 |
| 195 const char* Platform::GetExecutableName() { |
| 196 return executable_name_; |
| 197 } |
| 198 |
| 199 |
| 195 const char* Platform::ResolveExecutablePath() { | 200 const char* Platform::ResolveExecutablePath() { |
| 196 // Get the required length of the buffer. | 201 // Get the required length of the buffer. |
| 197 uint32_t path_size = 0; | 202 uint32_t path_size = 0; |
| 198 if (_NSGetExecutablePath(NULL, &path_size) == 0) { | 203 if (_NSGetExecutablePath(NULL, &path_size) == 0) { |
| 199 return NULL; | 204 return NULL; |
| 200 } | 205 } |
| 201 // Allocate buffer and get executable path. | 206 // Allocate buffer and get executable path. |
| 202 char* path = DartUtils::ScopedCString(path_size); | 207 char* path = DartUtils::ScopedCString(path_size); |
| 203 if (_NSGetExecutablePath(path, &path_size) != 0) { | 208 if (_NSGetExecutablePath(path, &path_size) != 0) { |
| 204 return NULL; | 209 return NULL; |
| 205 } | 210 } |
| 206 // Return the canonical path as the returned path might contain symlinks. | 211 // Return the canonical path as the returned path might contain symlinks. |
| 207 const char* canon_path = File::GetCanonicalPath(path); | 212 const char* canon_path = File::GetCanonicalPath(path); |
| 208 return canon_path; | 213 return canon_path; |
| 209 } | 214 } |
| 210 | 215 |
| 211 | 216 |
| 212 void Platform::Exit(int exit_code) { | 217 void Platform::Exit(int exit_code) { |
| 213 exit(exit_code); | 218 exit(exit_code); |
| 214 } | 219 } |
| 215 | 220 |
| 216 } // namespace bin | 221 } // namespace bin |
| 217 } // namespace dart | 222 } // namespace dart |
| 218 | 223 |
| 219 #endif // defined(HOST_OS_MACOS) | 224 #endif // defined(HOST_OS_MACOS) |
| OLD | NEW |