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

Unified Diff: utils/archive/input_stream.dart

Issue 10830191: Add ArchiveInputStream.readAll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
Index: utils/archive/input_stream.dart
diff --git a/utils/archive/input_stream.dart b/utils/archive/input_stream.dart
index 532dfbb4304b98a451ef0d860cff8809894e8911..5ca6c70e86d27f069e0fb84599bcd475f73864fb 100644
--- a/utils/archive/input_stream.dart
+++ b/utils/archive/input_stream.dart
@@ -62,6 +62,23 @@ class ArchiveInputStream {
bool get closed() => _id.value == null;
/**
+ * Reads the entire contents of the archive at once.
+ *
+ * Note that this is mutually exclusive with reading individual entries using
+ * [onEntry].
+ */
+ Future<List<CompleteArchiveEntry>> readAll() {
+ var completer = new Completer<List<Future<CompleteArchiveEntry>>>();
+ var result = <Future<CompleteArchiveEntry>>[];
+
+ this.onEntry = (entry) => result.add(entry.readAll());
+ this.onError = (e, stack) => completer.completeException(e, stack);
+ this.onClosed = () => completer.complete(result);
+
+ return completer.future.chain(Futures.wait);
+ }
+
+ /**
* Sets a callback to call when a new entry is read from the archive.
*
* The [ArchiveEntry] that's read from an archive initially only contains

Powered by Google App Engine
This is Rietveld 408576698