| OLD | NEW |
| 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 static intptr_t GetHandlerPort(Dart_Handle handle) { | 10 static intptr_t GetHandlerPort(Dart_Handle handle) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } else { | 72 } else { |
| 73 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 73 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 74 } | 74 } |
| 75 Dart_ExitScope(); | 75 Dart_ExitScope(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 | 78 |
| 79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { | 79 void FUNCTION_NAME(Directory_CreateTemp)(Dart_NativeArguments args) { |
| 80 Dart_EnterScope(); | 80 Dart_EnterScope(); |
| 81 Dart_Handle path = Dart_GetNativeArgument(args, 0); | 81 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 82 Dart_Handle number = Dart_GetNativeArgument(args, 1); | 82 Dart_Handle status_handle = Dart_GetNativeArgument(args, 1); |
| 83 Dart_Handle status_handle = Dart_GetNativeArgument(args, 2); | |
| 84 static const int kMaxChildOsErrorMessageLength = 256; | 83 static const int kMaxChildOsErrorMessageLength = 256; |
| 85 char os_error_message[kMaxChildOsErrorMessageLength]; | 84 char os_error_message[kMaxChildOsErrorMessageLength]; |
| 86 if (!Dart_IsString(path) || !Dart_IsInteger(number)) { | 85 if (!Dart_IsString(path)) { |
| 87 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); | 86 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); |
| 88 DartUtils::SetStringInstanceField( | 87 DartUtils::SetStringInstanceField( |
| 89 status_handle, "_errorMessage", "Invalid arguments"); | 88 status_handle, "_errorMessage", "Invalid arguments"); |
| 90 Dart_SetReturnValue(args, Dart_Null()); | 89 Dart_SetReturnValue(args, Dart_Null()); |
| 91 Dart_ExitScope(); | 90 Dart_ExitScope(); |
| 92 return; | 91 return; |
| 93 } | 92 } |
| 94 | 93 |
| 95 char* result = NULL; | 94 char* result = NULL; |
| 96 int error_code = Directory::CreateTemp(DartUtils::GetStringValue(path), | 95 int error_code = Directory::CreateTemp(DartUtils::GetStringValue(path), |
| 97 DartUtils::GetIntegerValue(number), | |
| 98 &result, | 96 &result, |
| 99 os_error_message, | 97 os_error_message, |
| 100 kMaxChildOsErrorMessageLength); | 98 kMaxChildOsErrorMessageLength); |
| 101 if (error_code == 0) { | 99 if (error_code == 0) { |
| 102 Dart_SetReturnValue(args, Dart_NewString(result)); | 100 Dart_SetReturnValue(args, Dart_NewString(result)); |
| 103 free(result); | 101 free(result); |
| 104 } else { | 102 } else { |
| 105 ASSERT(result == NULL); | 103 ASSERT(result == NULL); |
| 106 if (error_code == -1) { | 104 if (error_code == -1) { |
| 107 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); | 105 DartUtils::SetIntegerInstanceField(status_handle, "_errorCode", 0); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 123 Dart_EnterScope(); | 121 Dart_EnterScope(); |
| 124 Dart_Handle path = Dart_GetNativeArgument(args, 1); | 122 Dart_Handle path = Dart_GetNativeArgument(args, 1); |
| 125 if (Dart_IsString(path)) { | 123 if (Dart_IsString(path)) { |
| 126 bool deleted = Directory::Delete(DartUtils::GetStringValue(path)); | 124 bool deleted = Directory::Delete(DartUtils::GetStringValue(path)); |
| 127 Dart_SetReturnValue(args, Dart_NewBoolean(deleted)); | 125 Dart_SetReturnValue(args, Dart_NewBoolean(deleted)); |
| 128 } else { | 126 } else { |
| 129 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 127 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 130 } | 128 } |
| 131 Dart_ExitScope(); | 129 Dart_ExitScope(); |
| 132 } | 130 } |
| OLD | NEW |