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/directory.h" | 5 #include "bin/directory.h" |
6 | 6 |
7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
11 | 11 |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 namespace bin { | 14 namespace bin { |
15 | 15 |
16 // Forward declaration. | 16 // Forward declaration. |
17 static void DirectoryService(Dart_Port, Dart_Port, Dart_CObject*); | 17 static void DirectoryService(Dart_Port, Dart_Port, Dart_CObject*); |
18 | 18 |
19 NativeService Directory::directory_service_("DirectoryService", | 19 NativeService Directory::directory_service_("DirectoryService", |
20 DirectoryService, | 20 DirectoryService, |
21 16); | 21 16); |
22 | 22 |
23 | 23 |
24 void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) { | 24 void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) { |
25 char* current = Directory::Current(); | 25 char* current = Directory::Current(); |
26 if (current != NULL) { | 26 if (current != NULL) { |
27 Dart_SetReturnValue(args, DartUtils::NewString(current)); | 27 Dart_SetReturnValue(args, DartUtils::NewString(current)); |
28 free(current); | 28 free(current); |
| 29 } else { |
| 30 Dart_Handle err = DartUtils::NewDartOSError(); |
| 31 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 32 Dart_SetReturnValue(args, err); |
29 } | 33 } |
30 } | 34 } |
31 | 35 |
32 | 36 |
33 void FUNCTION_NAME(Directory_SetCurrent)(Dart_NativeArguments args) { | 37 void FUNCTION_NAME(Directory_SetCurrent)(Dart_NativeArguments args) { |
34 int argc = Dart_GetNativeArgumentCount(args); | 38 int argc = Dart_GetNativeArgumentCount(args); |
35 Dart_Handle path; | 39 Dart_Handle path; |
36 if (argc == 1) { | 40 if (argc == 1) { |
37 path = Dart_GetNativeArgument(args, 0); | 41 path = Dart_GetNativeArgument(args, 0); |
38 } | 42 } |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (listing->error()) { | 471 if (listing->error()) { |
468 listing->HandleError("Invalid path"); | 472 listing->HandleError("Invalid path"); |
469 listing->HandleDone(); | 473 listing->HandleDone(); |
470 } else { | 474 } else { |
471 while (ListNext(listing)) {} | 475 while (ListNext(listing)) {} |
472 } | 476 } |
473 } | 477 } |
474 | 478 |
475 } // namespace bin | 479 } // namespace bin |
476 } // namespace dart | 480 } // namespace dart |
OLD | NEW |