| 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/file.h" | 5 #include "bin/file.h" |
| 6 | 6 |
| 7 #include "bin/builtin.h" | 7 #include "bin/builtin.h" |
| 8 #include "bin/dartutils.h" | 8 #include "bin/dartutils.h" |
| 9 | 9 |
| 10 #include "include/dart_api.h" | 10 #include "include/dart_api.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 return true; | 39 return true; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) { | 43 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) { |
| 44 Dart_EnterScope(); | 44 Dart_EnterScope(); |
| 45 const char* filename = | 45 const char* filename = |
| 46 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 46 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 47 bool writable = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1)); | 47 bool writable = DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1)); |
| 48 File* file = File::OpenFile(filename, writable); | 48 File* file = File::Open(filename, writable); |
| 49 Dart_SetReturnValue(args, Dart_NewInteger(reinterpret_cast<intptr_t>(file))); | 49 Dart_SetReturnValue(args, Dart_NewInteger(reinterpret_cast<intptr_t>(file))); |
| 50 Dart_ExitScope(); | 50 Dart_ExitScope(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 void FUNCTION_NAME(File_Exists)(Dart_NativeArguments args) { | 54 void FUNCTION_NAME(File_Exists)(Dart_NativeArguments args) { |
| 55 Dart_EnterScope(); | 55 Dart_EnterScope(); |
| 56 const char* filename = | 56 const char* filename = |
| 57 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 57 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 58 bool exists = File::FileExists(filename); | 58 bool exists = File::Exists(filename); |
| 59 Dart_SetReturnValue(args, Dart_NewBoolean(exists)); | 59 Dart_SetReturnValue(args, Dart_NewBoolean(exists)); |
| 60 Dart_ExitScope(); | 60 Dart_ExitScope(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 void FUNCTION_NAME(File_Close)(Dart_NativeArguments args) { | 64 void FUNCTION_NAME(File_Close)(Dart_NativeArguments args) { |
| 65 Dart_EnterScope(); | 65 Dart_EnterScope(); |
| 66 intptr_t return_value = -1; | 66 intptr_t return_value = -1; |
| 67 intptr_t value = | 67 intptr_t value = |
| 68 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | 68 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 intptr_t value = | 235 intptr_t value = |
| 236 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | 236 DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); |
| 237 File* file = reinterpret_cast<File*>(value); | 237 File* file = reinterpret_cast<File*>(value); |
| 238 if (file != NULL) { | 238 if (file != NULL) { |
| 239 file->Flush(); | 239 file->Flush(); |
| 240 return_value = 0; | 240 return_value = 0; |
| 241 } | 241 } |
| 242 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); | 242 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| 243 Dart_ExitScope(); | 243 Dart_ExitScope(); |
| 244 } | 244 } |
| 245 |
| 246 |
| 247 void FUNCTION_NAME(File_Create)(Dart_NativeArguments args) { |
| 248 Dart_EnterScope(); |
| 249 const char* str = |
| 250 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 251 bool result = File::Create(str); |
| 252 Dart_SetReturnValue(args, Dart_NewBoolean(result)); |
| 253 Dart_ExitScope(); |
| 254 } |
| OLD | NEW |