| 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/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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { | 313 void FUNCTION_NAME(File_Delete)(Dart_NativeArguments args) { |
| 314 Dart_EnterScope(); | 314 Dart_EnterScope(); |
| 315 const char* str = | 315 const char* str = |
| 316 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 316 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 317 bool result = File::Delete(str); | 317 bool result = File::Delete(str); |
| 318 Dart_SetReturnValue(args, Dart_NewBoolean(result)); | 318 Dart_SetReturnValue(args, Dart_NewBoolean(result)); |
| 319 Dart_ExitScope(); | 319 Dart_ExitScope(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 | 322 |
| 323 void FUNCTION_NAME(File_Directory)(Dart_NativeArguments args) { |
| 324 Dart_EnterScope(); |
| 325 const char* str = |
| 326 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 327 char* str_copy = strdup(str); |
| 328 char* path = File::GetContainingDirectory(str_copy); |
| 329 if (path != NULL) { |
| 330 Dart_SetReturnValue(args, Dart_NewString(path)); |
| 331 } |
| 332 free(str_copy); |
| 333 free(path); |
| 334 Dart_ExitScope(); |
| 335 } |
| 336 |
| 337 |
| 323 void FUNCTION_NAME(File_FullPath)(Dart_NativeArguments args) { | 338 void FUNCTION_NAME(File_FullPath)(Dart_NativeArguments args) { |
| 324 Dart_EnterScope(); | 339 Dart_EnterScope(); |
| 325 const char* str = | 340 const char* str = |
| 326 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 341 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 327 char* path = File::GetCanonicalPath(str); | 342 char* path = File::GetCanonicalPath(str); |
| 328 if (path != NULL) { | 343 if (path != NULL) { |
| 329 Dart_SetReturnValue(args, Dart_NewString(path)); | 344 Dart_SetReturnValue(args, Dart_NewString(path)); |
| 330 free(path); | 345 free(path); |
| 331 } | 346 } |
| 332 Dart_ExitScope(); | 347 Dart_ExitScope(); |
| 333 } | 348 } |
| 334 | 349 |
| 335 | 350 |
| 336 void FUNCTION_NAME(File_OpenStdio)(Dart_NativeArguments args) { | 351 void FUNCTION_NAME(File_OpenStdio)(Dart_NativeArguments args) { |
| 337 Dart_EnterScope(); | 352 Dart_EnterScope(); |
| 338 int fd = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | 353 int fd = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); |
| 339 File* file = File::OpenStdio(fd); | 354 File* file = File::OpenStdio(fd); |
| 340 Dart_SetReturnValue(args, Dart_NewInteger(reinterpret_cast<intptr_t>(file))); | 355 Dart_SetReturnValue(args, Dart_NewInteger(reinterpret_cast<intptr_t>(file))); |
| 341 Dart_ExitScope(); | 356 Dart_ExitScope(); |
| 342 } | 357 } |
| 343 | 358 |
| 344 | 359 |
| 345 void FUNCTION_NAME(File_GetStdioHandleType)(Dart_NativeArguments args) { | 360 void FUNCTION_NAME(File_GetStdioHandleType)(Dart_NativeArguments args) { |
| 346 Dart_EnterScope(); | 361 Dart_EnterScope(); |
| 347 int fd = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); | 362 int fd = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 0)); |
| 348 File::StdioHandleType type = File::GetStdioHandleType(fd); | 363 File::StdioHandleType type = File::GetStdioHandleType(fd); |
| 349 Dart_SetReturnValue(args, Dart_NewInteger(type)); | 364 Dart_SetReturnValue(args, Dart_NewInteger(type)); |
| 350 Dart_ExitScope(); | 365 Dart_ExitScope(); |
| 351 } | 366 } |
| OLD | NEW |