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

Unified Diff: sdk/lib/io/file_impl.dart

Issue 2848703003: Fix a batch of DDC SDK compile errors. (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/core/string.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }
});
}
« 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