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

Side by Side Diff: sdk/lib/io/file_impl.dart

Issue 11412033: Rename File.readAsText to File.readAsString. There is no Text type in Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « sdk/lib/io/file.dart ('k') | tests/standalone/io/file_error_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 class _FileInputStream extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(String name) 6 _FileInputStream(String name)
7 : _data = const [], 7 : _data = const [],
8 _position = 0, 8 _position = 0,
9 _filePosition = 0 { 9 _filePosition = 0 {
10 var file = new File(name); 10 var file = new File(name);
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 var length = opened.lengthSync(); 602 var length = opened.lengthSync();
603 var result = new Uint8List(length); 603 var result = new Uint8List(length);
604 var read = opened.readListSync(result, 0, length); 604 var read = opened.readListSync(result, 0, length);
605 if (read != length) { 605 if (read != length) {
606 throw new FileIOException("Failed to read file"); 606 throw new FileIOException("Failed to read file");
607 } 607 }
608 opened.closeSync(); 608 opened.closeSync();
609 return result; 609 return result;
610 } 610 }
611 611
612 Future<String> readAsText([Encoding encoding = Encoding.UTF_8]) { 612 Future<String> readAsString([Encoding encoding = Encoding.UTF_8]) {
613 _ensureFileService(); 613 _ensureFileService();
614 return readAsBytes().transform((bytes) { 614 return readAsBytes().transform((bytes) {
615 if (bytes.length == 0) return ""; 615 if (bytes.length == 0) return "";
616 var decoder = _StringDecoders.decoder(encoding); 616 var decoder = _StringDecoders.decoder(encoding);
617 decoder.write(bytes); 617 decoder.write(bytes);
618 return decoder.decoded(); 618 return decoder.decoded();
619 }); 619 });
620 } 620 }
621 621
622 String readAsTextSync([Encoding encoding = Encoding.UTF_8]) { 622 String readAsStringSync([Encoding encoding = Encoding.UTF_8]) {
623 var decoder = _StringDecoders.decoder(encoding); 623 var decoder = _StringDecoders.decoder(encoding);
624 List<int> bytes = readAsBytesSync(); 624 List<int> bytes = readAsBytesSync();
625 if (bytes.length == 0) return ""; 625 if (bytes.length == 0) return "";
626 decoder.write(bytes); 626 decoder.write(bytes);
627 return decoder.decoded(); 627 return decoder.decoded();
628 } 628 }
629 629
630 List<String> _getDecodedLines(_StringDecoder decoder) { 630 List<String> _getDecodedLines(_StringDecoder decoder) {
631 List<String> result = []; 631 List<String> result = [];
632 var line = decoder.decodedLine; 632 var line = decoder.decodedLine;
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 new FileIOException("File closed '$_name'")); 1080 new FileIOException("File closed '$_name'"));
1081 }); 1081 });
1082 return completer.future; 1082 return completer.future;
1083 } 1083 }
1084 1084
1085 final String _name; 1085 final String _name;
1086 int _id; 1086 int _id;
1087 1087
1088 SendPort _fileService; 1088 SendPort _fileService;
1089 } 1089 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file.dart ('k') | tests/standalone/io/file_error_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698