Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Side by Side Diff: runtime/bin/directory.cc

Issue 8244001: Clean up directory listing interface. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "bin/directory.h" 6 #include "bin/directory.h"
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 void FUNCTION_NAME(Directory_Open)(Dart_NativeArguments args) {
11 Dart_EnterScope();
12 Dart_Handle directory_handle = Dart_GetNativeArgument(args, 0);
13 Dart_Handle path_handle = Dart_GetNativeArgument(args, 1);
14 if (!Dart_IsString(path_handle)) {
15 Dart_SetReturnValue(args, Dart_NewBoolean(false));
16 } else {
17 const char* path =
18 DartUtils::GetStringValue(path_handle);
19 intptr_t dir = 0;
20 bool success = Directory::Open(path, &dir);
21 if (success) {
22 DartUtils::SetIntegerInstanceField(directory_handle,
23 DartUtils::kIdFieldName,
24 dir);
25 }
26 Dart_SetReturnValue(args, Dart_NewBoolean(success));
27 }
28 Dart_ExitScope();
29 }
30
31 void FUNCTION_NAME(Directory_Close)(Dart_NativeArguments args) {
32 Dart_EnterScope();
33 intptr_t dir = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
34 bool success = Directory::Close(dir);
35 Dart_SetReturnValue(args, Dart_NewBoolean(success));
36 Dart_ExitScope();
37 }
38
39
40 static intptr_t GetHandlerPort(Dart_Handle handle) { 10 static intptr_t GetHandlerPort(Dart_Handle handle) {
41 if (Dart_IsNull(handle)) { 11 if (Dart_IsNull(handle)) {
42 // TODO(ager): Generalize this to Directory::kInvalidId. 12 // TODO(ager): Generalize this to Directory::kInvalidId.
43 return 0; 13 return 0;
44 } 14 }
45 return DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName); 15 return DartUtils::GetIntegerInstanceField(handle, DartUtils::kIdFieldName);
46 } 16 }
47 17
48 18
49 void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) { 19 void FUNCTION_NAME(Directory_List)(Dart_NativeArguments args) {
50 Dart_EnterScope(); 20 Dart_EnterScope();
51 Dart_Handle path = Dart_GetNativeArgument(args, 1); 21 Dart_Handle path = Dart_GetNativeArgument(args, 1);
52 intptr_t dir = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2)); 22 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 2));
53 bool recursive = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 3)); 23 Dart_Port dir_port = GetHandlerPort(Dart_GetNativeArgument(args, 3));
54 Dart_Port dir_handler_port = GetHandlerPort(Dart_GetNativeArgument(args, 4)); 24 Dart_Port file_port = GetHandlerPort(Dart_GetNativeArgument(args, 4));
55 Dart_Port file_handler_port = GetHandlerPort(Dart_GetNativeArgument(args, 5)); 25 Dart_Port done_port = GetHandlerPort(Dart_GetNativeArgument(args, 5));
56 Dart_Port done_handler_port = GetHandlerPort(Dart_GetNativeArgument(args, 6)); 26 Dart_Port error_port =
57 Dart_Port dir_error_handler_port = 27 GetHandlerPort(Dart_GetNativeArgument(args, 6));
58 GetHandlerPort(Dart_GetNativeArgument(args, 7));
59 ASSERT(Dart_IsString(path)); 28 ASSERT(Dart_IsString(path));
60 Directory::List(DartUtils::GetStringValue(path), 29 Directory::List(DartUtils::GetStringValue(path),
61 dir,
62 recursive, 30 recursive,
63 dir_handler_port, 31 dir_port,
64 file_handler_port, 32 file_port,
65 done_handler_port, 33 done_port,
66 dir_error_handler_port); 34 error_port);
67 Dart_ExitScope(); 35 Dart_ExitScope();
68 } 36 }
OLDNEW
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory.dart » ('j') | runtime/bin/directory.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698