Chromium Code Reviews| Index: runtime/bin/platform_macos.cc |
| diff --git a/runtime/bin/platform_macos.cc b/runtime/bin/platform_macos.cc |
| index 55ccd213f87b3e7ec1ea6b3192112cbea22c803c..3699a33ff736fb3208d359dd8b5dd8432f1e1a80 100644 |
| --- a/runtime/bin/platform_macos.cc |
| +++ b/runtime/bin/platform_macos.cc |
| @@ -5,6 +5,8 @@ |
| #include "platform/globals.h" |
| #if defined(TARGET_OS_MACOS) |
| +#include <mach-o/dyld.h> |
| + |
| #include "bin/platform.h" |
| #include <crt_externs.h> // NOLINT |
| @@ -75,6 +77,23 @@ void Platform::FreeEnvironment(char** env, intptr_t count) { |
| delete[] env; |
| } |
| + |
| +char* Platform::ResolveExecutablePath() { |
| + // Get the required length of the buffer. |
| + uint32_t path_size = 0; |
| + char* path = NULL; |
| + if (_NSGetExecutablePath(path, &path_size) != -1) { |
|
Lasse Reichstein Nielsen
2015/05/20 10:48:43
Could "!= -1" be ">= 0".
(I just don't like unname
Søren Gjesse
2015/05/20 11:14:24
Changed to "== 0" then. The documentation explicit
|
| + return NULL; |
| + } |
| + // Allocate buffer and get executable path. |
| + path = reinterpret_cast<char*>(malloc(path_size)); |
| + if (_NSGetExecutablePath(path, &path_size) != 0) { |
| + free(path); |
| + return NULL; |
| + } |
| + return path; |
| +} |
| + |
| } // namespace bin |
| } // namespace dart |