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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const char* DartUtils::RemoveScheme(const char* url) { | 225 const char* DartUtils::RemoveScheme(const char* url) { |
226 const char* colon = strchr(url, ':'); | 226 const char* colon = strchr(url, ':'); |
227 if (colon == NULL) { | 227 if (colon == NULL) { |
228 return url; | 228 return url; |
229 } else { | 229 } else { |
230 return colon + 1; | 230 return colon + 1; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 | 234 |
| 235 char* DartUtils::DirName(const char* url) { |
| 236 const char* slash = strrchr(url, File::PathSeparator()[0]); |
| 237 if (slash == NULL) { |
| 238 return strdup(url); |
| 239 } else { |
| 240 return strndup(url, slash - url + 1); |
| 241 } |
| 242 } |
| 243 |
| 244 |
235 void* DartUtils::OpenFile(const char* name, bool write) { | 245 void* DartUtils::OpenFile(const char* name, bool write) { |
236 File* file = File::Open(name, write ? File::kWriteTruncate : File::kRead); | 246 File* file = File::Open(name, write ? File::kWriteTruncate : File::kRead); |
237 return reinterpret_cast<void*>(file); | 247 return reinterpret_cast<void*>(file); |
238 } | 248 } |
239 | 249 |
240 | 250 |
241 void DartUtils::ReadFile(const uint8_t** data, | 251 void DartUtils::ReadFile(const uint8_t** data, |
242 intptr_t* len, | 252 intptr_t* len, |
243 void* stream) { | 253 void* stream) { |
244 ASSERT(data != NULL); | 254 ASSERT(data != NULL); |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 new CObjectString(CObject::NewString(os_error->message())); | 1199 new CObjectString(CObject::NewString(os_error->message())); |
1190 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 1200 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
1191 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 1201 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
1192 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 1202 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
1193 result->SetAt(2, error_message); | 1203 result->SetAt(2, error_message); |
1194 return result; | 1204 return result; |
1195 } | 1205 } |
1196 | 1206 |
1197 } // namespace bin | 1207 } // namespace bin |
1198 } // namespace dart | 1208 } // namespace dart |
OLD | NEW |