Chromium Code Reviews| Index: sdk/lib/io/file_impl.dart |
| diff --git a/sdk/lib/io/file_impl.dart b/sdk/lib/io/file_impl.dart |
| index fd66fc1b6094de886ce9e268d819bb502b783fa3..fe8a8bfbff80a69ebb57f326641a1f1e01e9dbef 100644 |
| --- a/sdk/lib/io/file_impl.dart |
| +++ b/sdk/lib/io/file_impl.dart |
| @@ -198,8 +198,7 @@ class _FileStreamConsumer extends StreamConsumer<List<int>> { |
| return completer.future; |
| } |
| - Future<File> close() => |
| - _openFuture.then<File>((openedFile) => openedFile.close()); |
| + Future close() => _openFuture.then((openedFile) => openedFile.close()); |
|
floitsch
2017/04/27 22:10:25
Please use my changes instead:
https://codereview.
Bob Nystrom
2017/04/28 00:13:07
Done. (FWIW, I changed it the way I did because _F
|
| } |
| // Class for encapsulating the native implementation of files. |
| @@ -555,11 +554,14 @@ class _File extends FileSystemEntity implements File { |
| Future<File> writeAsBytes(List<int> bytes, |
| {FileMode mode: FileMode.WRITE, bool flush: false}) { |
| - return open(mode: mode).then((file) { |
| - return file.writeFrom(bytes, 0, bytes.length).then((_) { |
| - if (flush) return file.flush().then((_) => this); |
| - return this; |
| - }).whenComplete(file.close); |
| + return open(mode: mode).then((file) async { |
|
floitsch
2017/04/27 22:10:25
The core libraries currently do not use 'async'. I
Bob Nystrom
2017/04/28 00:13:07
Took your change instead. I could have sworn I tri
|
| + try { |
| + await file.writeFrom(bytes, 0, bytes.length); |
| + if (flush) await file.flush(); |
| + return this as File; |
| + } finally { |
| + await file.close(); |
| + } |
| }); |
| } |