| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #library("entry"); | 5 #library("entry"); |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("archive.dart", prefix: "archive"); | 8 #import("archive.dart", prefix: "archive"); |
| 9 #import("entry_request.dart"); | 9 #import("entry_request.dart"); |
| 10 #import("read_request.dart", prefix: 'read'); | 10 #import("read_request.dart", prefix: 'read'); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 * The contents of an entry must be consumed before the next entry is read | 253 * The contents of an entry must be consumed before the next entry is read |
| 254 * from the parent [ArchiveInputStream]. This means that [openInputStream] | 254 * from the parent [ArchiveInputStream]. This means that [openInputStream] |
| 255 * must be called from the [ArchiveInputStream.onEntry] callback, or before | 255 * must be called from the [ArchiveInputStream.onEntry] callback, or before |
| 256 * the future returned by that callback completes. Once the next entry has | 256 * the future returned by that callback completes. Once the next entry has |
| 257 * been read, calling [openInputStream] will throw an [ArchiveException]. | 257 * been read, calling [openInputStream] will throw an [ArchiveException]. |
| 258 * | 258 * |
| 259 * Only one input stream may be opened per entry. | 259 * Only one input stream may be opened per entry. |
| 260 */ | 260 */ |
| 261 InputStream openInputStream() { | 261 InputStream openInputStream() { |
| 262 if (_archiveId == null) { | 262 if (_archiveId == null) { |
| 263 throw new UnsupportedOperationException("Cannot open input stream for " | 263 throw new UnsupportedError("Cannot open input stream for " |
| 264 "archive entry $pathname."); | 264 "archive entry $pathname."); |
| 265 } else if (_input != null) { | 265 } else if (_input != null) { |
| 266 throw new UnsupportedOperationException("An input stream has already been" | 266 throw new UnsupportedError("An input stream has already been" |
| 267 "opened for archive entry $pathname."); | 267 "opened for archive entry $pathname."); |
| 268 } | 268 } |
| 269 | 269 |
| 270 var inputCompleter = new Completer(); | 270 var inputCompleter = new Completer(); |
| 271 inputComplete = inputCompleter.future; | 271 inputComplete = inputCompleter.future; |
| 272 | 272 |
| 273 _input = new ListInputStream(); | 273 _input = new ListInputStream(); |
| 274 // TODO(nweiz): Report errors once issue 3657 is fixed | 274 // TODO(nweiz): Report errors once issue 3657 is fixed |
| 275 var future = _consumeInput().chain((_) { | 275 var future = _consumeInput().chain((_) { |
| 276 if (!_input.closed) _input.markEndOfStream(); | 276 if (!_input.closed) _input.markEndOfStream(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 class CompleteArchiveEntry extends ArchiveEntry { | 328 class CompleteArchiveEntry extends ArchiveEntry { |
| 329 /** The contents of the entry as bytes. */ | 329 /** The contents of the entry as bytes. */ |
| 330 final List<int> contentBytes; | 330 final List<int> contentBytes; |
| 331 | 331 |
| 332 /** The contents of the entry as a string. */ | 332 /** The contents of the entry as a string. */ |
| 333 String get contents => new String.fromCharCodes(contentBytes); | 333 String get contents => new String.fromCharCodes(contentBytes); |
| 334 | 334 |
| 335 CompleteArchiveEntry._(List properties, this.contentBytes) | 335 CompleteArchiveEntry._(List properties, this.contentBytes) |
| 336 : super.internal(properties, null); | 336 : super.internal(properties, null); |
| 337 } | 337 } |
| OLD | NEW |