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

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

Issue 2764943002: Fix some strong mode issues in the core libraries. (Closed)
Patch Set: Fix another type issue. Created 3 years, 9 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
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
203 .then((openedFile) => openedFile.close())
204 .then((_) => _file);
203 } 205 }
204 206
205 // Class for encapsulating the native implementation of files. 207 // Class for encapsulating the native implementation of files.
206 class _File extends FileSystemEntity implements File { 208 class _File extends FileSystemEntity implements File {
207 final String path; 209 final String path;
208 210
209 // Constructor for file. 211 // Constructor for file.
210 _File(this.path) { 212 _File(this.path) {
211 if (path is! String) { 213 if (path is! String) {
212 throw new ArgumentError('${Error.safeToString(path)} ' 214 throw new ArgumentError('${Error.safeToString(path)} '
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 551
550 Future<List<String>> readAsLines({Encoding encoding: UTF8}) => 552 Future<List<String>> readAsLines({Encoding encoding: UTF8}) =>
551 readAsString(encoding: encoding).then(const LineSplitter().convert); 553 readAsString(encoding: encoding).then(const LineSplitter().convert);
552 554
553 List<String> readAsLinesSync({Encoding encoding: UTF8}) => 555 List<String> readAsLinesSync({Encoding encoding: UTF8}) =>
554 const LineSplitter().convert(readAsStringSync(encoding: encoding)); 556 const LineSplitter().convert(readAsStringSync(encoding: encoding));
555 557
556 Future<File> writeAsBytes(List<int> bytes, 558 Future<File> writeAsBytes(List<int> bytes,
557 {FileMode mode: FileMode.WRITE, bool flush: false}) { 559 {FileMode mode: FileMode.WRITE, bool flush: false}) {
558 return open(mode: mode).then((file) { 560 return open(mode: mode).then((file) {
559 return file.writeFrom(bytes, 0, bytes.length).then((_) { 561 return file.writeFrom(bytes, 0, bytes.length).then<File>((_) {
560 if (flush) return file.flush().then((_) => this); 562 if (flush) return file.flush().then((_) => this);
561 return this; 563 return this;
562 }).whenComplete(file.close); 564 }).whenComplete(file.close);
563 }); 565 });
564 } 566 }
565 567
566 void writeAsBytesSync(List<int> bytes, 568 void writeAsBytesSync(List<int> bytes,
567 {FileMode mode: FileMode.WRITE, bool flush: false}) { 569 {FileMode mode: FileMode.WRITE, bool flush: false}) {
568 RandomAccessFile opened = openSync(mode: mode); 570 RandomAccessFile opened = openSync(mode: mode);
569 try { 571 try {
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 void _checkAvailable() { 1094 void _checkAvailable() {
1093 if (_asyncDispatched) { 1095 if (_asyncDispatched) {
1094 throw new FileSystemException( 1096 throw new FileSystemException(
1095 "An async operation is currently pending", path); 1097 "An async operation is currently pending", path);
1096 } 1098 }
1097 if (closed) { 1099 if (closed) {
1098 throw new FileSystemException("File closed", path); 1100 throw new FileSystemException("File closed", path);
1099 } 1101 }
1100 } 1102 }
1101 } 1103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698