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) || defined(TARGET_OS_IOS) |
Ivan Posva
2015/06/09 21:20:03
Please note that TARGET_OS_IOS also automatically
| |
7 | 7 |
8 #include <mach-o/dyld.h> | 8 #include <mach-o/dyld.h> |
9 | 9 |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
11 #include "bin/platform.h" | 11 #include "bin/platform.h" |
12 | 12 |
13 #if !defined(TARGET_OS_IOS) | |
13 #include <crt_externs.h> // NOLINT | 14 #include <crt_externs.h> // NOLINT |
15 #endif | |
14 #include <signal.h> // NOLINT | 16 #include <signal.h> // NOLINT |
15 #include <string.h> // NOLINT | 17 #include <string.h> // NOLINT |
16 #include <unistd.h> // NOLINT | 18 #include <unistd.h> // NOLINT |
17 | 19 |
18 #include "bin/fdutils.h" | 20 #include "bin/fdutils.h" |
19 | 21 |
20 | 22 |
21 namespace dart { | 23 namespace dart { |
22 namespace bin { | 24 namespace bin { |
23 | 25 |
(...skipping 26 matching lines...) Expand all Loading... | |
50 return "dylib"; | 52 return "dylib"; |
51 } | 53 } |
52 | 54 |
53 | 55 |
54 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { | 56 bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) { |
55 return gethostname(buffer, buffer_length) == 0; | 57 return gethostname(buffer, buffer_length) == 0; |
56 } | 58 } |
57 | 59 |
58 | 60 |
59 char** Platform::Environment(intptr_t* count) { | 61 char** Platform::Environment(intptr_t* count) { |
62 #if defined(TARGET_OS_IOS) | |
63 return NULL; | |
Ivan Posva
2015/06/09 21:20:03
Is there really no way to access environment varia
| |
64 #else | |
60 // Using environ directly is only safe as long as we do not | 65 // Using environ directly is only safe as long as we do not |
61 // provide access to modifying environment variables. | 66 // provide access to modifying environment variables. |
62 // On MacOS you have to do a bit of magic to get to the | 67 // On MacOS you have to do a bit of magic to get to the |
63 // environment strings. | 68 // environment strings. |
64 char** environ = *(_NSGetEnviron()); | 69 char** environ = *(_NSGetEnviron()); |
65 intptr_t i = 0; | 70 intptr_t i = 0; |
66 char** tmp = environ; | 71 char** tmp = environ; |
67 while (*(tmp++) != NULL) i++; | 72 while (*(tmp++) != NULL) i++; |
68 *count = i; | 73 *count = i; |
69 char** result = new char*[i]; | 74 char** result = new char*[i]; |
70 for (intptr_t current = 0; current < i; current++) { | 75 for (intptr_t current = 0; current < i; current++) { |
71 result[current] = environ[current]; | 76 result[current] = environ[current]; |
72 } | 77 } |
73 return result; | 78 return result; |
79 #endif | |
74 } | 80 } |
75 | 81 |
76 | 82 |
77 void Platform::FreeEnvironment(char** env, intptr_t count) { | 83 void Platform::FreeEnvironment(char** env, intptr_t count) { |
78 delete[] env; | 84 delete[] env; |
79 } | 85 } |
80 | 86 |
81 | 87 |
82 char* Platform::ResolveExecutablePath() { | 88 char* Platform::ResolveExecutablePath() { |
83 // Get the required length of the buffer. | 89 // Get the required length of the buffer. |
(...skipping 11 matching lines...) Expand all Loading... | |
95 // Return the canonical path as the returned path might contain symlinks. | 101 // Return the canonical path as the returned path might contain symlinks. |
96 char* canon_path = File::GetCanonicalPath(path); | 102 char* canon_path = File::GetCanonicalPath(path); |
97 free(path); | 103 free(path); |
98 return canon_path; | 104 return canon_path; |
99 } | 105 } |
100 | 106 |
101 } // namespace bin | 107 } // namespace bin |
102 } // namespace dart | 108 } // namespace dart |
103 | 109 |
104 #endif // defined(TARGET_OS_MACOS) | 110 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |