Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: runtime/bin/file.cc

Issue 63363010: Add support for working with large files, in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 Dart_Handle err = DartUtils::NewDartOSError(&os_error); 327 Dart_Handle err = DartUtils::NewDartOSError(&os_error);
328 if (Dart_IsError(err)) Dart_PropagateError(err); 328 if (Dart_IsError(err)) Dart_PropagateError(err);
329 Dart_SetReturnValue(args, err); 329 Dart_SetReturnValue(args, err);
330 } 330 }
331 } 331 }
332 332
333 333
334 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) { 334 void FUNCTION_NAME(File_Length)(Dart_NativeArguments args) {
335 File* file = GetFilePointer(Dart_GetNativeArgument(args, 0)); 335 File* file = GetFilePointer(Dart_GetNativeArgument(args, 0));
336 ASSERT(file != NULL); 336 ASSERT(file != NULL);
337 intptr_t return_value = file->Length(); 337 off64_t return_value = file->Length();
338 if (return_value >= 0) { 338 if (return_value >= 0) {
339 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); 339 Dart_SetReturnValue(args, Dart_NewInteger(return_value));
340 } else { 340 } else {
341 Dart_Handle err = DartUtils::NewDartOSError(); 341 Dart_Handle err = DartUtils::NewDartOSError();
342 if (Dart_IsError(err)) Dart_PropagateError(err); 342 if (Dart_IsError(err)) Dart_PropagateError(err);
343 Dart_SetReturnValue(args, err); 343 Dart_SetReturnValue(args, err);
344 } 344 }
345 } 345 }
346 346
347 347
348 void FUNCTION_NAME(File_LengthFromPath)(Dart_NativeArguments args) { 348 void FUNCTION_NAME(File_LengthFromPath)(Dart_NativeArguments args) {
349 const char* path = 349 const char* path =
350 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 350 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
351 intptr_t return_value = File::LengthFromPath(path); 351 off64_t return_value = File::LengthFromPath(path);
352 if (return_value >= 0) { 352 if (return_value >= 0) {
353 Dart_SetReturnValue(args, Dart_NewInteger(return_value)); 353 Dart_SetReturnValue(args, Dart_NewInteger(return_value));
354 } else { 354 } else {
355 Dart_Handle err = DartUtils::NewDartOSError(); 355 Dart_Handle err = DartUtils::NewDartOSError();
356 if (Dart_IsError(err)) Dart_PropagateError(err); 356 if (Dart_IsError(err)) Dart_PropagateError(err);
357 Dart_SetReturnValue(args, err); 357 Dart_SetReturnValue(args, err);
358 } 358 }
359 } 359 }
360 360
361 361
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 753 }
754 754
755 755
756 CObject* File::SetPositionRequest(const CObjectArray& request) { 756 CObject* File::SetPositionRequest(const CObjectArray& request) {
757 if (request.Length() == 2 && 757 if (request.Length() == 2 &&
758 request[0]->IsIntptr() && 758 request[0]->IsIntptr() &&
759 request[1]->IsInt32OrInt64()) { 759 request[1]->IsInt32OrInt64()) {
760 File* file = CObjectToFilePointer(request[0]); 760 File* file = CObjectToFilePointer(request[0]);
761 ASSERT(file != NULL); 761 ASSERT(file != NULL);
762 if (!file->IsClosed()) { 762 if (!file->IsClosed()) {
763 int64_t position = CObjectInt32OrInt64ToInt64(request[1]); 763 off64_t position = CObjectInt32OrInt64ToInt64(request[1]);
764 if (file->SetPosition(position)) { 764 if (file->SetPosition(position)) {
765 return CObject::True(); 765 return CObject::True();
766 } else { 766 } else {
767 return CObject::NewOSError(); 767 return CObject::NewOSError();
768 } 768 }
769 } else { 769 } else {
770 return CObject::FileClosedError(); 770 return CObject::FileClosedError();
771 } 771 }
772 } 772 }
773 return CObject::IllegalArgumentError(); 773 return CObject::IllegalArgumentError();
(...skipping 19 matching lines...) Expand all
793 } 793 }
794 return CObject::IllegalArgumentError(); 794 return CObject::IllegalArgumentError();
795 } 795 }
796 796
797 797
798 CObject* File::LengthRequest(const CObjectArray& request) { 798 CObject* File::LengthRequest(const CObjectArray& request) {
799 if (request.Length() == 1 && request[0]->IsIntptr()) { 799 if (request.Length() == 1 && request[0]->IsIntptr()) {
800 File* file = CObjectToFilePointer(request[0]); 800 File* file = CObjectToFilePointer(request[0]);
801 ASSERT(file != NULL); 801 ASSERT(file != NULL);
802 if (!file->IsClosed()) { 802 if (!file->IsClosed()) {
803 off_t return_value = file->Length(); 803 off64_t return_value = file->Length();
804 if (return_value >= 0) { 804 if (return_value >= 0) {
805 return new CObjectInt64(CObject::NewInt64(return_value)); 805 return new CObjectInt64(CObject::NewInt64(return_value));
806 } else { 806 } else {
807 return CObject::NewOSError(); 807 return CObject::NewOSError();
808 } 808 }
809 } else { 809 } else {
810 return CObject::FileClosedError(); 810 return CObject::FileClosedError();
811 } 811 }
812 } 812 }
813 return CObject::IllegalArgumentError(); 813 return CObject::IllegalArgumentError();
814 } 814 }
815 815
816 816
817 CObject* File::LengthFromPathRequest(const CObjectArray& request) { 817 CObject* File::LengthFromPathRequest(const CObjectArray& request) {
818 if (request.Length() == 1 && request[0]->IsString()) { 818 if (request.Length() == 1 && request[0]->IsString()) {
819 CObjectString filepath(request[0]); 819 CObjectString filepath(request[0]);
820 off_t return_value = File::LengthFromPath(filepath.CString()); 820 off64_t return_value = File::LengthFromPath(filepath.CString());
821 if (return_value >= 0) { 821 if (return_value >= 0) {
822 return new CObjectInt64(CObject::NewInt64(return_value)); 822 return new CObjectInt64(CObject::NewInt64(return_value));
823 } else { 823 } else {
824 return CObject::NewOSError(); 824 return CObject::NewOSError();
825 } 825 }
826 } 826 }
827 return CObject::IllegalArgumentError(); 827 return CObject::IllegalArgumentError();
828 } 828 }
829 829
830 830
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2)); 1156 CObjectArray* wrapper = new CObjectArray(CObject::NewArray(2));
1157 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess))); 1157 wrapper->SetAt(0, new CObjectInt32(CObject::NewInt32(CObject::kSuccess)));
1158 wrapper->SetAt(1, result); 1158 wrapper->SetAt(1, result);
1159 return wrapper; 1159 return wrapper;
1160 } 1160 }
1161 return CObject::IllegalArgumentError(); 1161 return CObject::IllegalArgumentError();
1162 } 1162 }
1163 1163
1164 } // namespace bin 1164 } // namespace bin
1165 } // namespace dart 1165 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | runtime/bin/file_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698