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/crypto.h" | 7 #include "bin/crypto.h" |
8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
9 #include "bin/extensions.h" | 9 #include "bin/extensions.h" |
10 #include "bin/file.h" | 10 #include "bin/file.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 bool DartUtils::IsDartIOLibURL(const char* url_name) { | 173 bool DartUtils::IsDartIOLibURL(const char* url_name) { |
174 return (strcmp(url_name, kIOLibURL) == 0); | 174 return (strcmp(url_name, kIOLibURL) == 0); |
175 } | 175 } |
176 | 176 |
177 | 177 |
178 bool DartUtils::IsDartBuiltinLibURL(const char* url_name) { | 178 bool DartUtils::IsDartBuiltinLibURL(const char* url_name) { |
179 return (strcmp(url_name, kBuiltinLibURL) == 0); | 179 return (strcmp(url_name, kBuiltinLibURL) == 0); |
180 } | 180 } |
181 | 181 |
182 | 182 |
| 183 void* DartUtils::MapExecutable(const char* name, intptr_t* len) { |
| 184 File* file = File::Open(name, File::kRead); |
| 185 if (file == NULL) { |
| 186 return NULL; |
| 187 } |
| 188 void* addr = file->MapExecutable(len); |
| 189 file->Release(); |
| 190 return addr; |
| 191 } |
| 192 |
| 193 |
183 void* DartUtils::OpenFile(const char* name, bool write) { | 194 void* DartUtils::OpenFile(const char* name, bool write) { |
184 File* file = File::Open(name, write ? File::kWriteTruncate : File::kRead); | 195 File* file = File::Open(name, write ? File::kWriteTruncate : File::kRead); |
185 return reinterpret_cast<void*>(file); | 196 return reinterpret_cast<void*>(file); |
186 } | 197 } |
187 | 198 |
188 | 199 |
189 void DartUtils::ReadFile(const uint8_t** data, | 200 void DartUtils::ReadFile(const uint8_t** data, |
190 intptr_t* len, | 201 intptr_t* len, |
191 void* stream) { | 202 void* stream) { |
192 ASSERT(data != NULL); | 203 ASSERT(data != NULL); |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 new CObjectString(CObject::NewString(os_error->message())); | 1267 new CObjectString(CObject::NewString(os_error->message())); |
1257 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1268 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1258 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1269 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1259 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1270 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1260 result->SetAt(2, error_message); | 1271 result->SetAt(2, error_message); |
1261 return result; | 1272 return result; |
1262 } | 1273 } |
1263 | 1274 |
1264 } // namespace bin | 1275 } // namespace bin |
1265 } // namespace dart | 1276 } // namespace dart |
OLD | NEW |