Chromium Code Reviews| 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(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 7 | 7 |
| 8 #include <mach-o/dyld.h> | |
| 9 | |
| 8 #include "bin/platform.h" | 10 #include "bin/platform.h" |
| 9 | 11 |
| 10 #include <crt_externs.h> // NOLINT | 12 #include <crt_externs.h> // NOLINT |
| 11 #include <signal.h> // NOLINT | 13 #include <signal.h> // NOLINT |
| 12 #include <string.h> // NOLINT | 14 #include <string.h> // NOLINT |
| 13 #include <unistd.h> // NOLINT | 15 #include <unistd.h> // NOLINT |
| 14 | 16 |
| 15 #include "bin/fdutils.h" | 17 #include "bin/fdutils.h" |
| 16 | 18 |
| 17 | 19 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 result[current] = environ[current]; | 70 result[current] = environ[current]; |
| 69 } | 71 } |
| 70 return result; | 72 return result; |
| 71 } | 73 } |
| 72 | 74 |
| 73 | 75 |
| 74 void Platform::FreeEnvironment(char** env, intptr_t count) { | 76 void Platform::FreeEnvironment(char** env, intptr_t count) { |
| 75 delete[] env; | 77 delete[] env; |
| 76 } | 78 } |
| 77 | 79 |
| 80 | |
| 81 char* Platform::ResolveExecutablePath() { | |
| 82 // Get the required length of the buffer. | |
| 83 uint32_t path_size = 0; | |
| 84 char* path = NULL; | |
| 85 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
| |
| 86 return NULL; | |
| 87 } | |
| 88 // Allocate buffer and get executable path. | |
| 89 path = reinterpret_cast<char*>(malloc(path_size)); | |
| 90 if (_NSGetExecutablePath(path, &path_size) != 0) { | |
| 91 free(path); | |
| 92 return NULL; | |
| 93 } | |
| 94 return path; | |
| 95 } | |
| 96 | |
| 78 } // namespace bin | 97 } // namespace bin |
| 79 } // namespace dart | 98 } // namespace dart |
| 80 | 99 |
| 81 #endif // defined(TARGET_OS_MACOS) | 100 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |