| 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 "bin/extensions.h" | 5 #include "bin/extensions.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| 11 #include "platform/globals.h" | 11 #include "platform/globals.h" |
| 12 #include "bin/dartutils.h" | 12 #include "bin/dartutils.h" |
| 13 #include "bin/file.h" | 13 #include "bin/file.h" |
| 14 | 14 |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 namespace bin { | 17 namespace bin { |
| 18 | 18 |
| 19 Dart_Handle Extensions::LoadExtension(const char* extension_path, | 19 Dart_Handle Extensions::LoadExtension(const char* extension_path, |
| 20 Dart_Handle parent_library) { | 20 Dart_Handle parent_library) { |
| 21 if (strncmp(extension_path, "http://", 7) == 0) { |
| 22 return Dart_NewApiError("Cannot load native extensions over http:"); |
| 23 } |
| 24 |
| 21 char* library_path = strdup(extension_path); | 25 char* library_path = strdup(extension_path); |
| 22 | 26 |
| 23 if (library_path == NULL) { | 27 if (library_path == NULL) { |
| 24 return Dart_NewApiError("Out of memory in LoadExtension"); | 28 return Dart_NewApiError("Out of memory in LoadExtension"); |
| 25 } | 29 } |
| 26 | 30 |
| 27 // Extract the directory and the extension name from the path. | 31 // Extract the directory and the extension name from the path. |
| 28 char* last_path_separator = strrchr(library_path, '/'); | 32 char* last_path_separator = strrchr(library_path, '/'); |
| 29 if (last_path_separator == NULL) { | 33 if (last_path_separator == NULL) { |
| 30 last_path_separator = strrchr(library_path, '\\'); | 34 last_path_separator = strrchr(library_path, '\\'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 for (int i = 0; strings[i] != NULL; i++) { | 74 for (int i = 0; strings[i] != NULL; i++) { |
| 71 index += snprintf(result + index, size - index, "%s", strings[i]); | 75 index += snprintf(result + index, size - index, "%s", strings[i]); |
| 72 } | 76 } |
| 73 ASSERT(index == size - 1); | 77 ASSERT(index == size - 1); |
| 74 ASSERT(result[size - 1] == '\0'); | 78 ASSERT(result[size - 1] == '\0'); |
| 75 return result; | 79 return result; |
| 76 } | 80 } |
| 77 | 81 |
| 78 } // namespace bin | 82 } // namespace bin |
| 79 } // namespace dart | 83 } // namespace dart |
| OLD | NEW |