| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "bin/io_buffer.h" | 9 #include "bin/io_buffer.h" |
| 10 #include "bin/thread.h" | 10 #include "bin/thread.h" |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 Dart_Handle err = DartUtils::NewDartOSError(&os_error); | 326 Dart_Handle err = DartUtils::NewDartOSError(&os_error); |
| 327 if (Dart_IsError(err)) Dart_PropagateError(err); | 327 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 328 Dart_SetReturnValue(args, err); | 328 Dart_SetReturnValue(args, err); |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 | 332 |
| 333 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) { | 333 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) { |
| 334 File* file = GetFilePointer(Dart_GetNativeArgument(args, 0)); | 334 File* file = GetFilePointer(Dart_GetNativeArgument(args, 0)); |
| 335 ASSERT(file != NULL); | 335 ASSERT(file != NULL); |
| 336 off64_t return_value = file->Length(); | 336 int64_t return_value = file->Length(); |
| 337 if (return_value >= 0) { | 337 if (return_value >= 0) { |
| 338 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); | 338 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| 339 } else { | 339 } else { |
| 340 Dart_Handle err = DartUtils::NewDartOSError(); | 340 Dart_Handle err = DartUtils::NewDartOSError(); |
| 341 if (Dart_IsError(err)) Dart_PropagateError(err); | 341 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 342 Dart_SetReturnValue(args, err); | 342 Dart_SetReturnValue(args, err); |
| 343 } | 343 } |
| 344 } | 344 } |
| 345 | 345 |
| 346 | 346 |
| 347 void FUNCTION_NAME(File_LengthFromPath)(Dart_NativeArguments args) { | 347 void FUNCTION_NAME(File_LengthFromPath)(Dart_NativeArguments args) { |
| 348 const char* path = | 348 const char* path = |
| 349 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); | 349 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); |
| 350 off64_t return_value = File::LengthFromPath(path); | 350 int64_t return_value = File::LengthFromPath(path); |
| 351 if (return_value >= 0) { | 351 if (return_value >= 0) { |
| 352 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); | 352 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); |
| 353 } else { | 353 } else { |
| 354 Dart_Handle err = DartUtils::NewDartOSError(); | 354 Dart_Handle err = DartUtils::NewDartOSError(); |
| 355 if (Dart_IsError(err)) Dart_PropagateError(err); | 355 if (Dart_IsError(err)) Dart_PropagateError(err); |
| 356 Dart_SetReturnValue(args, err); | 356 Dart_SetReturnValue(args, err); |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 | 360 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 } | 782 } |
| 783 | 783 |
| 784 | 784 |
| 785 CObject* File::SetPositionRequest(const CObjectArray& request) { | 785 CObject* File::SetPositionRequest(const CObjectArray& request) { |
| 786 if (request.Length() == 2 && | 786 if (request.Length() == 2 && |
| 787 request[0]->IsIntptr() && | 787 request[0]->IsIntptr() && |
| 788 request[1]->IsInt32OrInt64()) { | 788 request[1]->IsInt32OrInt64()) { |
| 789 File* file = CObjectToFilePointer(request[0]); | 789 File* file = CObjectToFilePointer(request[0]); |
| 790 ASSERT(file != NULL); | 790 ASSERT(file != NULL); |
| 791 if (!file->IsClosed()) { | 791 if (!file->IsClosed()) { |
| 792 off64_t position = CObjectInt32OrInt64ToInt64(request[1]); | 792 int64_t position = CObjectInt32OrInt64ToInt64(request[1]); |
| 793 if (file->SetPosition(position)) { | 793 if (file->SetPosition(position)) { |
| 794 return CObject::True(); | 794 return CObject::True(); |
| 795 } else { | 795 } else { |
| 796 return CObject::NewOSError(); | 796 return CObject::NewOSError(); |
| 797 } | 797 } |
| 798 } else { | 798 } else { |
| 799 return CObject::FileClosedError(); | 799 return CObject::FileClosedError(); |
| 800 } | 800 } |
| 801 } | 801 } |
| 802 return CObject::IllegalArgumentError(); | 802 return CObject::IllegalArgumentError(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 822 } | 822 } |
| 823 return CObject::IllegalArgumentError(); | 823 return CObject::IllegalArgumentError(); |
| 824 } | 824 } |
| 825 | 825 |
| 826 | 826 |
| 827 CObject* File::LengthRequest(const CObjectArray& request) { | 827 CObject* File::LengthRequest(const CObjectArray& request) { |
| 828 if (request.Length() == 1 && request[0]->IsIntptr()) { | 828 if (request.Length() == 1 && request[0]->IsIntptr()) { |
| 829 File* file = CObjectToFilePointer(request[0]); | 829 File* file = CObjectToFilePointer(request[0]); |
| 830 ASSERT(file != NULL); | 830 ASSERT(file != NULL); |
| 831 if (!file->IsClosed()) { | 831 if (!file->IsClosed()) { |
| 832 off64_t return_value = file->Length(); | 832 int64_t return_value = file->Length(); |
| 833 if (return_value >= 0) { | 833 if (return_value >= 0) { |
| 834 return new CObjectInt64(CObject::NewInt64(return_value)); | 834 return new CObjectInt64(CObject::NewInt64(return_value)); |
| 835 } else { | 835 } else { |
| 836 return CObject::NewOSError(); | 836 return CObject::NewOSError(); |
| 837 } | 837 } |
| 838 } else { | 838 } else { |
| 839 return CObject::FileClosedError(); | 839 return CObject::FileClosedError(); |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 return CObject::IllegalArgumentError(); | 842 return CObject::IllegalArgumentError(); |
| 843 } | 843 } |
| 844 | 844 |
| 845 | 845 |
| 846 CObject* File::LengthFromPathRequest(const CObjectArray& request) { | 846 CObject* File::LengthFromPathRequest(const CObjectArray& request) { |
| 847 if (request.Length() == 1 && request[0]->IsString()) { | 847 if (request.Length() == 1 && request[0]->IsString()) { |
| 848 CObjectString filepath(request[0]); | 848 CObjectString filepath(request[0]); |
| 849 off64_t return_value = File::LengthFromPath(filepath.CString()); | 849 int64_t return_value = File::LengthFromPath(filepath.CString()); |
| 850 if (return_value >= 0) { | 850 if (return_value >= 0) { |
| 851 return new CObjectInt64(CObject::NewInt64(return_value)); | 851 return new CObjectInt64(CObject::NewInt64(return_value)); |
| 852 } else { | 852 } else { |
| 853 return CObject::NewOSError(); | 853 return CObject::NewOSError(); |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 return CObject::IllegalArgumentError(); | 856 return CObject::IllegalArgumentError(); |
| 857 } | 857 } |
| 858 | 858 |
| 859 | 859 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2)); | 1185 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2)); |
| 1186 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess))); | 1186 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess))); |
| 1187 wrapper->SetAt(1, result); | 1187 wrapper->SetAt(1, result); |
| 1188 return wrapper; | 1188 return wrapper; |
| 1189 } | 1189 } |
| 1190 return CObject::IllegalArgumentError(); | 1190 return CObject::IllegalArgumentError(); |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 } // namespace bin | 1193 } // namespace bin |
| 1194 } // namespace dart | 1194 } // namespace dart |
| OLD | NEW |