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/dartutils.h" | 5 #include "bin/dartutils.h" |
6 | 6 |
7 #include "bin/file.h" | 7 #include "bin/file.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/globals.h" | 9 #include "platform/globals.h" |
10 | 10 |
11 const char* DartUtils::kDartScheme = "dart:"; | 11 const char* DartUtils::kDartScheme = "dart:"; |
12 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; | 12 const char* DartUtils::kBuiltinLibURL = "dart:builtin"; |
13 const char* DartUtils::kCoreLibURL = "dart:core"; | 13 const char* DartUtils::kCoreLibURL = "dart:core"; |
14 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; | 14 const char* DartUtils::kCoreImplLibURL = "dart:coreimpl"; |
15 const char* DartUtils::kCoreNativeWrappersLibURL = "dart:nativewrappers"; | 15 const char* DartUtils::kIOLibURL = "dart:io"; |
| 16 |
| 17 |
16 const char* DartUtils::kIdFieldName = "_id"; | 18 const char* DartUtils::kIdFieldName = "_id"; |
17 | 19 |
18 | 20 |
19 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, | 21 static const char* MapLibraryUrl(CommandLineOptions* url_mapping, |
20 const char* url_string) { | 22 const char* url_string) { |
21 ASSERT(url_mapping != NULL); | 23 ASSERT(url_mapping != NULL); |
22 // We need to check if the passed in url is found in the url_mapping array, | 24 // We need to check if the passed in url is found in the url_mapping array, |
23 // in that case use the mapped entry. | 25 // in that case use the mapped entry. |
24 int len = strlen(url_string); | 26 int len = strlen(url_string); |
25 for (int idx = 0; idx < url_mapping->count(); idx++) { | 27 for (int idx = 0; idx < url_mapping->count(); idx++) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 93 |
92 | 94 |
93 bool DartUtils::IsDartSchemeURL(const char* url_name) { | 95 bool DartUtils::IsDartSchemeURL(const char* url_name) { |
94 static const intptr_t kDartSchemeLen = strlen(kDartScheme); | 96 static const intptr_t kDartSchemeLen = strlen(kDartScheme); |
95 // If the URL starts with "dart:" then it is considered as a special | 97 // If the URL starts with "dart:" then it is considered as a special |
96 // library URL which is handled differently from other URLs. | 98 // library URL which is handled differently from other URLs. |
97 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); | 99 return (strncmp(url_name, kDartScheme, kDartSchemeLen) == 0); |
98 } | 100 } |
99 | 101 |
100 | 102 |
| 103 bool DartUtils::IsDartIOLibURL(const char* url_name) { |
| 104 return (strcmp(url_name, kIOLibURL) == 0); |
| 105 } |
| 106 |
| 107 |
| 108 |
101 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, | 109 Dart_Handle DartUtils::CanonicalizeURL(CommandLineOptions* url_mapping, |
102 Dart_Handle library, | 110 Dart_Handle library, |
103 const char* url_str) { | 111 const char* url_str) { |
104 // Get the url of the including library. | 112 // Get the url of the including library. |
105 Dart_Handle library_url = Dart_LibraryUrl(library); | 113 Dart_Handle library_url = Dart_LibraryUrl(library); |
106 if (Dart_IsError(library_url)) { | 114 if (Dart_IsError(library_url)) { |
107 return Dart_Error("accessing library url failed"); | 115 return Dart_Error("accessing library url failed"); |
108 } | 116 } |
109 if (!Dart_IsString8(library_url)) { | 117 if (!Dart_IsString8(library_url)) { |
110 return Dart_Error("library url is not a string"); | 118 return Dart_Error("library url is not a string"); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 path, File::PathSeparator(), filename); | 222 path, File::PathSeparator(), filename); |
215 | 223 |
216 free(path); | 224 free(path); |
217 char* canonical_filename = File::GetCanonicalPath(absolute_filename); | 225 char* canonical_filename = File::GetCanonicalPath(absolute_filename); |
218 if (canonical_filename == NULL) { | 226 if (canonical_filename == NULL) { |
219 return absolute_filename; | 227 return absolute_filename; |
220 } | 228 } |
221 free(absolute_filename); | 229 free(absolute_filename); |
222 return canonical_filename; | 230 return canonical_filename; |
223 } | 231 } |
OLD | NEW |