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> | 8 #include <mach-o/dyld.h> |
9 | 9 |
| 10 #include "bin/file.h" |
10 #include "bin/platform.h" | 11 #include "bin/platform.h" |
11 | 12 |
12 #include <crt_externs.h> // NOLINT | 13 #include <crt_externs.h> // NOLINT |
13 #include <signal.h> // NOLINT | 14 #include <signal.h> // NOLINT |
14 #include <string.h> // NOLINT | 15 #include <string.h> // NOLINT |
15 #include <unistd.h> // NOLINT | 16 #include <unistd.h> // NOLINT |
16 | 17 |
17 #include "bin/fdutils.h" | 18 #include "bin/fdutils.h" |
18 | 19 |
19 | 20 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 char* path = NULL; | 85 char* path = NULL; |
85 if (_NSGetExecutablePath(path, &path_size) == 0) { | 86 if (_NSGetExecutablePath(path, &path_size) == 0) { |
86 return NULL; | 87 return NULL; |
87 } | 88 } |
88 // Allocate buffer and get executable path. | 89 // Allocate buffer and get executable path. |
89 path = reinterpret_cast<char*>(malloc(path_size)); | 90 path = reinterpret_cast<char*>(malloc(path_size)); |
90 if (_NSGetExecutablePath(path, &path_size) != 0) { | 91 if (_NSGetExecutablePath(path, &path_size) != 0) { |
91 free(path); | 92 free(path); |
92 return NULL; | 93 return NULL; |
93 } | 94 } |
94 return path; | 95 // Return the canonical path as the returned path might contain symlinks. |
| 96 char* canon_path = File::GetCanonicalPath(path); |
| 97 free(path); |
| 98 return canon_path; |
95 } | 99 } |
96 | 100 |
97 } // namespace bin | 101 } // namespace bin |
98 } // namespace dart | 102 } // namespace dart |
99 | 103 |
100 #endif // defined(TARGET_OS_MACOS) | 104 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |