| 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" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 | 64 |
| 65 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { | 65 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
| 66 Dart_EnterScope(); | 66 Dart_EnterScope(); |
| 67 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 67 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 68 Dart_Handle status_handle = Dart_GetNativeArgument(args, 1); | 68 Dart_Handle status_handle = Dart_GetNativeArgument(args, 1); |
| 69 static const int kMaxChildOsErrorMessageLength = 256; | 69 static const int kMaxChildOsErrorMessageLength = 256; |
| 70 char os_error_message[kMaxChildOsErrorMessageLength]; | 70 char os_error_message[kMaxChildOsErrorMessageLength]; |
| 71 if (!Dart_IsString(path)) { | 71 if (!Dart_IsString(path)) { |
| 72 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); | 72 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); |
| 73 DartUtils::SetStringInstanceField( | 73 DartUtils::SetStringField( |
| 74 status_handle, "_errorMessage", "Invalid arguments"); | 74 status_handle, "_errorMessage", "Invalid arguments"); |
| 75 Dart_SetReturnValue(args, Dart_Null()); | 75 Dart_SetReturnValue(args, Dart_Null()); |
| 76 Dart_ExitScope(); | 76 Dart_ExitScope(); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| 80 char* result = NULL; | 80 char* result = NULL; |
| 81 int error_code = Directory::CreateTemp(DartUtils::GetStringValue(path), | 81 int error_code = Directory::CreateTemp(DartUtils::GetStringValue(path), |
| 82 &result, | 82 &result, |
| 83 os_error_message, | 83 os_error_message, |
| 84 kMaxChildOsErrorMessageLength); | 84 kMaxChildOsErrorMessageLength); |
| 85 if (error_code == 0) { | 85 if (error_code == 0) { |
| 86 Dart_SetReturnValue(args, Dart_NewString(result)); | 86 Dart_SetReturnValue(args, Dart_NewString(result)); |
| 87 free(result); | 87 free(result); |
| 88 } else { | 88 } else { |
| 89 ASSERT(result == NULL); | 89 ASSERT(result == NULL); |
| 90 if (error_code == -1) { | 90 if (error_code == -1) { |
| 91 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); | 91 DartUtils::SetIntegerField(status_handle, "_errorCode", 0); |
| 92 DartUtils::SetStringInstanceField( | 92 DartUtils::SetStringField( |
| 93 status_handle, "_errorMessage", "Invalid arguments"); | 93 status_handle, "_errorMessage", "Invalid arguments"); |
| 94 } else { | 94 } else { |
| 95 DartUtils::SetIntegerInstanceField( | 95 DartUtils::SetIntegerField( |
| 96 status_handle, "_errorCode", error_code); | 96 status_handle, "_errorCode", error_code); |
| 97 DartUtils::SetStringInstanceField( | 97 DartUtils::SetStringField( |
| 98 status_handle, "_errorMessage", os_error_message); | 98 status_handle, "_errorMessage", os_error_message); |
| 99 } | 99 } |
| 100 Dart_SetReturnValue(args, Dart_Null()); | 100 Dart_SetReturnValue(args, Dart_Null()); |
| 101 } | 101 } |
| 102 Dart_ExitScope(); | 102 Dart_ExitScope(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| 106 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { | 106 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { |
| 107 Dart_EnterScope(); | 107 Dart_EnterScope(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 308 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
| 309 } | 309 } |
| 310 | 310 |
| 311 | 311 |
| 312 bool DirectoryListing::HandleError(char* message) { | 312 bool DirectoryListing::HandleError(char* message) { |
| 313 // TODO(sgjesse): Pass flags to indicate whether error | 313 // TODO(sgjesse): Pass flags to indicate whether error |
| 314 // responses are needed. | 314 // responses are needed. |
| 315 CObjectArray* response = NewResponse(kListError, message); | 315 CObjectArray* response = NewResponse(kListError, message); |
| 316 return Dart_PostCObject(response_port_, response->AsApiCObject()); | 316 return Dart_PostCObject(response_port_, response->AsApiCObject()); |
| 317 } | 317 } |
| OLD | NEW |