| 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 /** | 5 /** |
| 6 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 library io; | 8 library io; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 var buffer = new StringBuffer(); | 601 var buffer = new StringBuffer(); |
| 602 stream.onClosed = () => completer.complete(buffer.toString()); | 602 stream.onClosed = () => completer.complete(buffer.toString()); |
| 603 stream.onData = () => buffer.add(stream.read()); | 603 stream.onData = () => buffer.add(stream.read()); |
| 604 stream.onError = (e) => completer.completeException(e, stackTrace); | 604 stream.onError = (e) => completer.completeException(e, stackTrace); |
| 605 return completer.future; | 605 return completer.future; |
| 606 } | 606 } |
| 607 | 607 |
| 608 /// Wrap an InputStream in a ListInputStream. This eagerly drains the [source] | 608 /// Wrap an InputStream in a ListInputStream. This eagerly drains the [source] |
| 609 /// input stream. This is useful for spawned processes which will not exit until | 609 /// input stream. This is useful for spawned processes which will not exit until |
| 610 /// their output streams have been drained. | 610 /// their output streams have been drained. |
| 611 /// TODO(rnystrom): Get rid of this once #7218 is fixed. | 611 /// TODO(rnystrom): We should use this logic anywhere we spawn a process. |
| 612 InputStream wrapInputStream(InputStream source) { | 612 InputStream wrapInputStream(InputStream source) { |
| 613 var sink = new ListInputStream(); | 613 var sink = new ListInputStream(); |
| 614 pipeInputToInput(source, sink); | 614 pipeInputToInput(source, sink); |
| 615 return sink; | 615 return sink; |
| 616 } | 616 } |
| 617 | 617 |
| 618 /// Spawns and runs the process located at [executable], passing in [args]. | 618 /// Spawns and runs the process located at [executable], passing in [args]. |
| 619 /// Returns a [Future] that will complete with the results of the process after | 619 /// Returns a [Future] that will complete with the results of the process after |
| 620 /// it has ended. | 620 /// it has ended. |
| 621 /// | 621 /// |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 return new Directory(entry); | 1029 return new Directory(entry); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 /** | 1032 /** |
| 1033 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 1033 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 1034 */ | 1034 */ |
| 1035 Uri _getUri(uri) { | 1035 Uri _getUri(uri) { |
| 1036 if (uri is Uri) return uri; | 1036 if (uri is Uri) return uri; |
| 1037 return new Uri.fromString(uri); | 1037 return new Uri.fromString(uri); |
| 1038 } | 1038 } |
| OLD | NEW |