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

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

Issue 154273003: Make std* blocking file-descriptors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update with bug. Created 6 years, 10 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/_internal/pub/pub.status ('k') | sdk/lib/io/stdio.dart » ('j') | 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 c30d8aed3e8951e207b35194cffe490539f36e9a..dfa75f6ebd181e7fe183d530b539f0685605e00b 100644
--- a/sdk/lib/io/file_impl.dart
+++ b/sdk/lib/io/file_impl.dart
@@ -190,23 +190,26 @@ class _FileStreamConsumer extends StreamConsumer<List<int>> {
Completer<File> completer = new Completer<File>();
_openFuture
.then((openedFile) {
+ void error(e, [StackTrace stackTrace]) {
+ _subscription.cancel();
+ openedFile.close();
+ completer.completeError(e, stackTrace);
+ }
_subscription = stream.listen(
(d) {
_subscription.pause();
- openedFile.writeFrom(d, 0, d.length)
- .then((_) => _subscription.resume())
- .catchError((e) {
- openedFile.close();
- completer.completeError(e);
- });
+ try {
+ openedFile.writeFrom(d, 0, d.length)
+ .then((_) => _subscription.resume(),
+ onError: error);
+ } catch (e, stackTrace) {
+ error(e, stackTrace);
+ }
},
onDone: () {
completer.complete(_file);
},
- onError: (e, [StackTrace stackTrace]) {
- openedFile.close();
- completer.completeError(e, stackTrace);
- },
+ onError: error,
cancelOnError: true);
})
.catchError((e) {
« no previous file with comments | « sdk/lib/_internal/pub/pub.status ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698