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

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

Issue 2848703003: Fix a batch of DDC SDK compile errors. (Closed)
Patch Set: Revise. Created 3 years, 7 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
« no previous file with comments | « sdk/lib/core/string.dart ('k') | no next file » | 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 class _FileStream extends Stream<List<int>> { 10 class _FileStream extends Stream<List<int>> {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 error(e, stackTrace); 192 error(e, stackTrace);
193 } 193 }
194 }, onDone: () { 194 }, onDone: () {
195 completer.complete(_file); 195 completer.complete(_file);
196 }, onError: error, cancelOnError: true); 196 }, onError: error, cancelOnError: true);
197 }).catchError(completer.completeError); 197 }).catchError(completer.completeError);
198 return completer.future; 198 return completer.future;
199 } 199 }
200 200
201 Future<File> close() => 201 Future<File> close() =>
202 _openFuture.then<File>((openedFile) => openedFile.close()); 202 _openFuture.then((openedFile) => openedFile.close()).then((_) => _file);
203 } 203 }
204 204
205 // Class for encapsulating the native implementation of files. 205 // Class for encapsulating the native implementation of files.
206 class _File extends FileSystemEntity implements File { 206 class _File extends FileSystemEntity implements File {
207 final String path; 207 final String path;
208 208
209 // Constructor for file. 209 // Constructor for file.
210 _File(this.path) { 210 _File(this.path) {
211 if (path is! String) { 211 if (path is! String) {
212 throw new ArgumentError('${Error.safeToString(path)} ' 212 throw new ArgumentError('${Error.safeToString(path)} '
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 Future<List<String>> readAsLines({Encoding encoding: UTF8}) => 550 Future<List<String>> readAsLines({Encoding encoding: UTF8}) =>
551 readAsString(encoding: encoding).then(const LineSplitter().convert); 551 readAsString(encoding: encoding).then(const LineSplitter().convert);
552 552
553 List<String> readAsLinesSync({Encoding encoding: UTF8}) => 553 List<String> readAsLinesSync({Encoding encoding: UTF8}) =>
554 const LineSplitter().convert(readAsStringSync(encoding: encoding)); 554 const LineSplitter().convert(readAsStringSync(encoding: encoding));
555 555
556 Future<File> writeAsBytes(List<int> bytes, 556 Future<File> writeAsBytes(List<int> bytes,
557 {FileMode mode: FileMode.WRITE, bool flush: false}) { 557 {FileMode mode: FileMode.WRITE, bool flush: false}) {
558 return open(mode: mode).then((file) { 558 return open(mode: mode).then((file) {
559 return file.writeFrom(bytes, 0, bytes.length).then((_) { 559 return file.writeFrom(bytes, 0, bytes.length).then<File>((_) {
560 if (flush) return file.flush().then((_) => this); 560 if (flush) return file.flush().then((_) => this);
561 return this; 561 return this;
562 }).whenComplete(file.close); 562 }).whenComplete(file.close);
563 }); 563 });
564 } 564 }
565 565
566 void writeAsBytesSync(List<int> bytes, 566 void writeAsBytesSync(List<int> bytes,
567 {FileMode mode: FileMode.WRITE, bool flush: false}) { 567 {FileMode mode: FileMode.WRITE, bool flush: false}) {
568 RandomAccessFile opened = openSync(mode: mode); 568 RandomAccessFile opened = openSync(mode: mode);
569 try { 569 try {
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 void _checkAvailable() { 1064 void _checkAvailable() {
1065 if (_asyncDispatched) { 1065 if (_asyncDispatched) {
1066 throw new FileSystemException( 1066 throw new FileSystemException(
1067 "An async operation is currently pending", path); 1067 "An async operation is currently pending", path);
1068 } 1068 }
1069 if (closed) { 1069 if (closed) {
1070 throw new FileSystemException("File closed", path); 1070 throw new FileSystemException("File closed", path);
1071 } 1071 }
1072 } 1072 }
1073 } 1073 }
OLDNEW
« no previous file with comments | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698