OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/file.h" | 5 #include "bin/file.h" |
6 | 6 |
7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
9 #include "bin/io_buffer.h" | 9 #include "bin/io_buffer.h" |
10 #include "bin/thread.h" | 10 #include "bin/thread.h" |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 Dart_SetReturnValue(args, Dart_NewBoolean(result)); | 418 Dart_SetReturnValue(args, Dart_NewBoolean(result)); |
419 } else { | 419 } else { |
420 Dart_Handle err = DartUtils::NewDartOSError(); | 420 Dart_Handle err = DartUtils::NewDartOSError(); |
421 if (Dart_IsError(err)) Dart_PropagateError(err); | 421 if (Dart_IsError(err)) Dart_PropagateError(err); |
422 Dart_SetReturnValue(args, err); | 422 Dart_SetReturnValue(args, err); |
423 } | 423 } |
424 Dart_ExitScope(); | 424 Dart_ExitScope(); |
425 } | 425 } |
426 | 426 |
427 | 427 |
| 428 void FUNCTION_NAME(File_CreateLink)(Dart_NativeArguments args) { |
| 429 Dart_EnterScope(); |
| 430 if (Dart_IsString(Dart_GetNativeArgument(args, 0)) && |
| 431 Dart_IsString(Dart_GetNativeArgument(args, 1))) { |
| 432 const char* name = |
| 433 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 434 const char* target = |
| 435 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); |
| 436 if (!File::CreateLink(name, target)) { |
| 437 Dart_Handle err = DartUtils::NewDartOSError(); |
| 438 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 439 Dart_SetReturnValue(args, err); |
| 440 } |
| 441 } else { |
| 442 OSError os_error(-1, "Invalid argument", OSError::kUnknown); |
| 443 Dart_Handle err = DartUtils::NewDartOSError(&os_error); |
| 444 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 445 Dart_SetReturnValue(args, err); |
| 446 } |
| 447 Dart_ExitScope(); |
| 448 } |
| 449 |
| 450 |
428 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { | 451 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { |
429 Dart_EnterScope(); | 452 Dart_EnterScope(); |
430 const char* str = | 453 const char* str = |
431 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 454 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
432 bool result = File::Delete(str); | 455 bool result = File::Delete(str); |
433 if (result) { | 456 if (result) { |
434 Dart_SetReturnValue(args, Dart_NewBoolean(result)); | 457 Dart_SetReturnValue(args, Dart_NewBoolean(result)); |
435 } else { | 458 } else { |
436 Dart_Handle err = DartUtils::NewDartOSError(); | 459 Dart_Handle err = DartUtils::NewDartOSError(); |
437 if (Dart_IsError(err)) Dart_PropagateError(err); | 460 if (Dart_IsError(err)) Dart_PropagateError(err); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 Dart_EnterScope(); | 1032 Dart_EnterScope(); |
1010 Dart_SetReturnValue(args, Dart_Null()); | 1033 Dart_SetReturnValue(args, Dart_Null()); |
1011 Dart_Port service_port = File::GetServicePort(); | 1034 Dart_Port service_port = File::GetServicePort(); |
1012 if (service_port != ILLEGAL_PORT) { | 1035 if (service_port != ILLEGAL_PORT) { |
1013 // Return a send port for the service port. | 1036 // Return a send port for the service port. |
1014 Dart_Handle send_port = Dart_NewSendPort(service_port); | 1037 Dart_Handle send_port = Dart_NewSendPort(service_port); |
1015 Dart_SetReturnValue(args, send_port); | 1038 Dart_SetReturnValue(args, send_port); |
1016 } | 1039 } |
1017 Dart_ExitScope(); | 1040 Dart_ExitScope(); |
1018 } | 1041 } |
OLD | NEW |