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

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

Issue 14150002: Remove StreamSink(replaced by EventSink) and make IOSink extend EventSink. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « sdk/lib/async/stream_controller.dart ('k') | sdk/lib/io/http_impl.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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 551
552 List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8}) { 552 List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8}) {
553 return _decodeLines(readAsBytesSync(), encoding); 553 return _decodeLines(readAsBytesSync(), encoding);
554 } 554 }
555 555
556 Future<File> writeAsBytes(List<int> bytes, 556 Future<File> writeAsBytes(List<int> bytes,
557 {FileMode mode: FileMode.WRITE}) { 557 {FileMode mode: FileMode.WRITE}) {
558 try { 558 try {
559 IOSink<File> sink = openWrite(mode: mode); 559 IOSink<File> sink = openWrite(mode: mode);
560 sink.writeBytes(bytes); 560 sink.add(bytes);
561 sink.close(); 561 sink.close();
562 return sink.done.then((_) => this);; 562 return sink.done.then((_) => this);;
563 } catch (e) { 563 } catch (e) {
564 return new Future.immediateError(e); 564 return new Future.immediateError(e);
565 } 565 }
566 } 566 }
567 567
568 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}) { 568 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}) {
569 RandomAccessFile opened = openSync(mode: mode); 569 RandomAccessFile opened = openSync(mode: mode);
570 opened.writeListSync(bytes, 0, bytes.length); 570 opened.writeListSync(bytes, 0, bytes.length);
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 new FileIOException("File closed '$_path'")); 1054 new FileIOException("File closed '$_path'"));
1055 }); 1055 });
1056 return completer.future; 1056 return completer.future;
1057 } 1057 }
1058 1058
1059 final String _path; 1059 final String _path;
1060 int _id; 1060 int _id;
1061 1061
1062 SendPort _fileService; 1062 SendPort _fileService;
1063 } 1063 }
OLDNEW
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698