| 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 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 Dart_ExitScope(); | 38 Dart_ExitScope(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { | 42 void FUNCTION_NAME(Directory_Exists)(Dart_NativeArguments args) { |
| 43 static const int kError = -1; | 43 static const int kError = -1; |
| 44 static const int kExists = 1; | 44 static const int kExists = 1; |
| 45 static const int kDoesNotExist = 0; | 45 static const int kDoesNotExist = 0; |
| 46 Dart_EnterScope(); | 46 Dart_EnterScope(); |
| 47 Dart_Handle path = Dart_GetNativeArgument(args, 1); | 47 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 48 if (Dart_IsString(path)) { | 48 if (Dart_IsString(path)) { |
| 49 Directory::ExistsResult result = | 49 Directory::ExistsResult result = |
| 50 Directory::Exists(DartUtils::GetStringValue(path)); | 50 Directory::Exists(DartUtils::GetStringValue(path)); |
| 51 int return_value = kError; | 51 int return_value = kError; |
| 52 if (result == Directory::EXISTS) { | 52 if (result == Directory::EXISTS) { |
| 53 return_value = kExists; | 53 return_value = kExists; |
| 54 } | 54 } |
| 55 if (result == Directory::DOES_NOT_EXIST) { | 55 if (result == Directory::DOES_NOT_EXIST) { |
| 56 return_value = kDoesNotExist; | 56 return_value = kDoesNotExist; |
| 57 } | 57 } |
| 58 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); | 58 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| 59 } else { | 59 } else { |
| 60 Dart_SetReturnValue(args, Dart_NewInteger(kDoesNotExist)); | 60 Dart_SetReturnValue(args, Dart_NewInteger(kDoesNotExist)); |
| 61 } | 61 } |
| 62 Dart_ExitScope(); | 62 Dart_ExitScope(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 | 65 |
| 66 void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) { | 66 void FUNCTION_NAME(Directory_Create)(Dart_NativeArguments args) { |
| 67 Dart_EnterScope(); | 67 Dart_EnterScope(); |
| 68 Dart_Handle path = Dart_GetNativeArgument(args, 1); | 68 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 69 if (Dart_IsString(path)) { | 69 if (Dart_IsString(path)) { |
| 70 bool created = Directory::Create(DartUtils::GetStringValue(path)); | 70 bool created = Directory::Create(DartUtils::GetStringValue(path)); |
| 71 Dart_SetReturnValue(args, Dart_NewBoolean(created)); | 71 Dart_SetReturnValue(args, Dart_NewBoolean(created)); |
| 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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 status_handle, "_errorMessage", os_error_message); | 112 status_handle, "_errorMessage", os_error_message); |
| 113 } | 113 } |
| 114 Dart_SetReturnValue(args, Dart_Null()); | 114 Dart_SetReturnValue(args, Dart_Null()); |
| 115 } | 115 } |
| 116 Dart_ExitScope(); | 116 Dart_ExitScope(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { | 120 void FUNCTION_NAME(Directory_Delete)(Dart_NativeArguments args) { |
| 121 Dart_EnterScope(); | 121 Dart_EnterScope(); |
| 122 Dart_Handle path = Dart_GetNativeArgument(args, 1); | 122 Dart_Handle path = Dart_GetNativeArgument(args, 0); |
| 123 if (Dart_IsString(path)) { | 123 if (Dart_IsString(path)) { |
| 124 bool deleted = Directory::Delete(DartUtils::GetStringValue(path)); | 124 bool deleted = Directory::Delete(DartUtils::GetStringValue(path)); |
| 125 Dart_SetReturnValue(args, Dart_NewBoolean(deleted)); | 125 Dart_SetReturnValue(args, Dart_NewBoolean(deleted)); |
| 126 } else { | 126 } else { |
| 127 Dart_SetReturnValue(args, Dart_NewBoolean(false)); | 127 Dart_SetReturnValue(args, Dart_NewBoolean(false)); |
| 128 } | 128 } |
| 129 Dart_ExitScope(); | 129 Dart_ExitScope(); |
| 130 } | 130 } |
| OLD | NEW |