Chromium Code Reviews| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 const char* name = | 432 const char* name = |
| 433 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 433 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 434 const char* target = | 434 const char* target = |
| 435 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); | 435 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1)); |
| 436 if (!File::CreateLink(name, target)) { | 436 if (!File::CreateLink(name, target)) { |
| 437 Dart_Handle err = DartUtils::NewDartOSError(); | 437 Dart_Handle err = DartUtils::NewDartOSError(); |
| 438 if (Dart_IsError(err)) Dart_PropagateError(err); | 438 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 439 Dart_SetReturnValue(args, err); | 439 Dart_SetReturnValue(args, err); |
| 440 } | 440 } |
| 441 } else { | 441 } else { |
| 442 OSError os_error(-1, "Invalid argument", OSError::kUnknown); | 442 Dart_Handle err = DartUtils::NewDartArgumentError( |
| 443 Dart_Handle err = DartUtils::NewDartOSError(&os_error); | 443 "Non-string argument to Link.create"); |
| 444 if (Dart_IsError(err)) Dart_PropagateError(err); | 444 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 445 Dart_SetReturnValue(args, err); | 445 Dart_SetReturnValue(args, err); |
| 446 } | 446 } |
| 447 Dart_ExitScope(); | |
| 448 } | |
| 449 | |
| 450 | |
| 451 void FUNCTION_NAME(File_LinkTarget)(Dart_NativeArguments args) { | |
| 452 Dart_EnterScope(); | |
| 453 if (Dart_IsString(Dart_GetNativeArgument(args, 0))) { | |
| 454 const char* name = | |
| 455 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | |
| 456 char* target = File::LinkTarget(name); | |
| 457 if (target == NULL) { | |
| 458 Dart_Handle err = DartUtils::NewDartOSError(); | |
|
Søren Gjesse
2013/03/18 12:28:03
For Windows there are cases where there is no dire
Bill Hesse
2013/03/18 16:13:27
Fixed. All returns of NULL from windows set an OS
| |
| 459 if (Dart_IsError(err)) Dart_PropagateError(err); | |
| 460 Dart_SetReturnValue(args, err); | |
| 461 } else { | |
| 462 Dart_SetReturnValue(args, DartUtils::NewString(target)); | |
| 463 free(target); | |
| 464 } | |
| 465 } else { | |
| 466 Dart_Handle err = DartUtils::NewDartArgumentError( | |
| 467 "Non-string argument to Link.target"); | |
| 468 if (Dart_IsError(err)) Dart_PropagateError(err); | |
| 469 Dart_SetReturnValue(args, err); | |
| 470 } | |
| 447 Dart_ExitScope(); | 471 Dart_ExitScope(); |
| 448 } | 472 } |
| 449 | 473 |
| 450 | 474 |
| 451 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { | 475 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { |
| 452 Dart_EnterScope(); | 476 Dart_EnterScope(); |
| 453 const char* str = | 477 const char* str = |
| 454 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 478 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 455 bool result = File::Delete(str); | 479 bool result = File::Delete(str); |
| 456 if (result) { | 480 if (result) { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1032 Dart_EnterScope(); | 1056 Dart_EnterScope(); |
| 1033 Dart_SetReturnValue(args, Dart_Null()); | 1057 Dart_SetReturnValue(args, Dart_Null()); |
| 1034 Dart_Port service_port = File::GetServicePort(); | 1058 Dart_Port service_port = File::GetServicePort(); |
| 1035 if (service_port != ILLEGAL_PORT) { | 1059 if (service_port != ILLEGAL_PORT) { |
| 1036 // Return a send port for the service port. | 1060 // Return a send port for the service port. |
| 1037 Dart_Handle send_port = Dart_NewSendPort(service_port); | 1061 Dart_Handle send_port = Dart_NewSendPort(service_port); |
| 1038 Dart_SetReturnValue(args, send_port); | 1062 Dart_SetReturnValue(args, send_port); |
| 1039 } | 1063 } |
| 1040 Dart_ExitScope(); | 1064 Dart_ExitScope(); |
| 1041 } | 1065 } |
| OLD | NEW |