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

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

Issue 22927016: Remove the LineTransformer from dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed one status file Created 7 years, 4 months 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 | « pkg/scheduled_test/test/scheduled_process_test.dart ('k') | sdk/lib/io/string_transformer.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) 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 part of dart.io; 5 part of dart.io;
6 6
7 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 List<int> bytes = readAsBytesSync(); 514 List<int> bytes = readAsBytesSync();
515 return _decodeString(bytes, encoding); 515 return _decodeString(bytes, encoding);
516 } 516 }
517 517
518 static List<String> _decodeLines(List<int> bytes, Encoding encoding) { 518 static List<String> _decodeLines(List<int> bytes, Encoding encoding) {
519 if (bytes.length == 0) return []; 519 if (bytes.length == 0) return [];
520 var list = []; 520 var list = [];
521 var controller = new StreamController(sync: true); 521 var controller = new StreamController(sync: true);
522 controller.stream 522 controller.stream
523 .transform(new StringDecoder(encoding)) 523 .transform(new StringDecoder(encoding))
524 .transform(new LineTransformer()) 524 .transform(new LineSplitter())
525 .listen((line) => list.add(line)); 525 .listen((line) => list.add(line));
526 controller.add(bytes); 526 controller.add(bytes);
527 controller.close(); 527 controller.close();
528 return list; 528 return list;
529 } 529 }
530 530
531 Future<List<String>> readAsLines({Encoding encoding: Encoding.UTF_8}) { 531 Future<List<String>> readAsLines({Encoding encoding: Encoding.UTF_8}) {
532 _ensureFileService(); 532 _ensureFileService();
533 return readAsBytes().then((bytes) { 533 return readAsBytes().then((bytes) {
534 return _decodeLines(bytes, encoding); 534 return _decodeLines(bytes, encoding);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 void _checkNotClosed() { 977 void _checkNotClosed() {
978 if (closed) { 978 if (closed) {
979 throw new FileException("File closed", path); 979 throw new FileException("File closed", path);
980 } 980 }
981 } 981 }
982 982
983 Future _closedException() { 983 Future _closedException() {
984 return new Future.error(new FileException("File closed", path)); 984 return new Future.error(new FileException("File closed", path));
985 } 985 }
986 } 986 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/test/scheduled_process_test.dart ('k') | sdk/lib/io/string_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698