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 dart::Mutex Directory::mutex_; | 12 dart::Mutex Directory::mutex_; |
13 int Directory::service_ports_size_ = 0; | 13 int Directory::service_ports_size_ = 0; |
14 Dart_Port* Directory::service_ports_ = NULL; | 14 Dart_Port* Directory::service_ports_ = NULL; |
15 int Directory::service_ports_index_ = 0; | 15 int Directory::service_ports_index_ = 0; |
16 | 16 |
| 17 void FUNCTION_NAME(Directory_Current)(Dart_NativeArguments args) { |
| 18 Dart_EnterScope(); |
| 19 char* current = Directory::Current(); |
| 20 if (current != NULL) { |
| 21 Dart_SetReturnValue(args, Dart_NewString(current)); |
| 22 free(current); |
| 23 } |
| 24 Dart_ExitScope(); |
| 25 } |
| 26 |
| 27 |
17 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { | 28 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { |
18 static const int kError = -1; | 29 static const int kError = -1; |
19 static const int kExists = 1; | 30 static const int kExists = 1; |
20 static const int kDoesNotExist = 0; | 31 static const int kDoesNotExist = 0; |
21 Dart_EnterScope(); | 32 Dart_EnterScope(); |
22 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 33 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
23 if (Dart_IsString(path)) { | 34 if (Dart_IsString(path)) { |
24 Directory::ExistsResult result = | 35 Directory::ExistsResult result = |
25 Directory::Exists(DartUtils::GetStringValue(path)); | 36 Directory::Exists(DartUtils::GetStringValue(path)); |
26 int return_value = kError; | 37 int return_value = kError; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 308 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
298 } | 309 } |
299 | 310 |
300 | 311 |
301 bool DirectoryListing::HandleError(char* message) { | 312 bool DirectoryListing::HandleError(char* message) { |
302 // TODO(sgjesse): Pass flags to indicate whether error | 313 // TODO(sgjesse): Pass flags to indicate whether error |
303 // responses are needed. | 314 // responses are needed. |
304 CObjectArray* response = NewResponse(kListError, message); | 315 CObjectArray* response = NewResponse(kListError, message); |
305 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 316 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
306 } | 317 } |
OLD | NEW |