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 /// Helper functionality to make working with IO easier. | 5 /// Helper functionality to make working with IO easier. |
6 library io; | 6 library io; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 log.fine("Extracting .tar.gz stream to $destination."); | 772 log.fine("Extracting .tar.gz stream to $destination."); |
773 | 773 |
774 if (Platform.operatingSystem == "windows") { | 774 if (Platform.operatingSystem == "windows") { |
775 return _extractTarGzWindows(stream, destination); | 775 return _extractTarGzWindows(stream, destination); |
776 } | 776 } |
777 | 777 |
778 var completer = new Completer<int>(); | 778 var completer = new Completer<int>(); |
779 var processFuture = startProcess("tar", | 779 var processFuture = startProcess("tar", |
780 ["--extract", "--gunzip", "--directory", destination]); | 780 ["--extract", "--gunzip", "--directory", destination]); |
781 processFuture.then((process) { | 781 processFuture.then((process) { |
782 process.onExit = completer.complete; | 782 process.onExit = (exitCode) => completer.complete(exitCode); |
783 stream.pipe(process.stdin); | 783 stream.pipe(process.stdin); |
784 process.stdout.pipe(stdout, close: false); | 784 process.stdout.pipe(stdout, close: false); |
785 process.stderr.pipe(stderr, close: false); | 785 process.stderr.pipe(stderr, close: false); |
786 }).catchError((e) { | 786 }).catchError((e) { |
787 completer.completeError(e.error, e.stackTrace); | 787 completer.completeError(e.error, e.stackTrace); |
788 }); | 788 }); |
789 | 789 |
790 return completer.future.then((exitCode) { | 790 return completer.future.then((exitCode) { |
791 log.fine("Extracted .tar.gz stream to $destination. Exit code $exitCode."); | 791 log.fine("Extracted .tar.gz stream to $destination. Exit code $exitCode."); |
792 // TODO(rnystrom): Does anything check this result value? If not, it should | 792 // TODO(rnystrom): Does anything check this result value? If not, it should |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 Directory _getDirectory(entry) { | 964 Directory _getDirectory(entry) { |
965 if (entry is Directory) return entry; | 965 if (entry is Directory) return entry; |
966 return new Directory(entry); | 966 return new Directory(entry); |
967 } | 967 } |
968 | 968 |
969 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 969 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
970 Uri _getUri(uri) { | 970 Uri _getUri(uri) { |
971 if (uri is Uri) return uri; | 971 if (uri is Uri) return uri; |
972 return new Uri.fromString(uri); | 972 return new Uri.fromString(uri); |
973 } | 973 } |
OLD | NEW |