| 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' as archive; | 8 import 'archive.dart' as archive; |
| 9 import 'entry_request.dart'; | 9 import 'entry_request.dart'; |
| 10 import 'read_request.dart' as read; | 10 import 'read_request.dart' as read; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 * copies of the fields in this entry. | 204 * copies of the fields in this entry. |
| 205 * | 205 * |
| 206 * This may not be called if [openInputStream] is called, and vice versa. | 206 * This may not be called if [openInputStream] is called, and vice versa. |
| 207 */ | 207 */ |
| 208 Future<CompleteArchiveEntry> readAll() { | 208 Future<CompleteArchiveEntry> readAll() { |
| 209 var stream = openInputStream(); | 209 var stream = openInputStream(); |
| 210 var buffer = <int>[]; | 210 var buffer = <int>[]; |
| 211 var completer = new Completer<List<int>>(); | 211 var completer = new Completer<List<int>>(); |
| 212 | 212 |
| 213 stream.onData = () => buffer.addAll(stream.read()); | 213 stream.onData = () => buffer.addAll(stream.read()); |
| 214 stream.onError = completer.completeException; | 214 stream.onError = completer.completeError; |
| 215 stream.onClosed = () => completer.complete(buffer); | 215 stream.onClosed = () => completer.complete(buffer); |
| 216 | 216 |
| 217 return Futures.wait([call(CLONE, _id), completer.future]) | 217 return Futures.wait([call(CLONE, _id), completer.future]) |
| 218 .then((list) => new CompleteArchiveEntry._(list[0], list[1])); | 218 .then((list) => new CompleteArchiveEntry._(list[0], list[1])); |
| 219 } | 219 } |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * Set a property value with index [value] on the local representation of the | 222 * Set a property value with index [value] on the local representation of the |
| 223 * archive entry and on the native representation. | 223 * archive entry and on the native representation. |
| 224 */ | 224 */ |
| (...skipping 103 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 |