| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 } | 543 } |
| 544 | 544 |
| 545 /// Creates a temporary directory and passes its path to [fn]. Once the [Future] | 545 /// Creates a temporary directory and passes its path to [fn]. Once the [Future] |
| 546 /// returned by [fn] completes, the temporary directory and all its contents | 546 /// returned by [fn] completes, the temporary directory and all its contents |
| 547 /// will be deleted. [fn] can also return `null`, in which case the temporary | 547 /// will be deleted. [fn] can also return `null`, in which case the temporary |
| 548 /// directory is deleted immediately afterwards. | 548 /// directory is deleted immediately afterwards. |
| 549 /// | 549 /// |
| 550 /// Returns a future that completes to the value that the future returned from | 550 /// Returns a future that completes to the value that the future returned from |
| 551 /// [fn] completes to. | 551 /// [fn] completes to. |
| 552 Future withTempDir(Future fn(String path)) { | 552 Future withTempDir(Future fn(String path)) { |
| 553 return new Future.of(() { | 553 return new Future.sync(() { |
| 554 var tempDir = createTempDir(); | 554 var tempDir = createTempDir(); |
| 555 return new Future.of(() => fn(tempDir)) | 555 return new Future.sync(() => fn(tempDir)) |
| 556 .whenComplete(() => deleteEntry(tempDir)); | 556 .whenComplete(() => deleteEntry(tempDir)); |
| 557 }); | 557 }); |
| 558 } | 558 } |
| 559 | 559 |
| 560 /// Extracts a `.tar.gz` file from [stream] to [destination]. Returns whether | 560 /// Extracts a `.tar.gz` file from [stream] to [destination]. Returns whether |
| 561 /// or not the extraction was successful. | 561 /// or not the extraction was successful. |
| 562 Future<bool> extractTarGz(Stream<List<int>> stream, String destination) { | 562 Future<bool> extractTarGz(Stream<List<int>> stream, String destination) { |
| 563 log.fine("Extracting .tar.gz stream to $destination."); | 563 log.fine("Extracting .tar.gz stream to $destination."); |
| 564 | 564 |
| 565 if (Platform.operatingSystem == "windows") { | 565 if (Platform.operatingSystem == "windows") { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 731 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
| 732 | 732 |
| 733 bool get success => exitCode == 0; | 733 bool get success => exitCode == 0; |
| 734 } | 734 } |
| 735 | 735 |
| 736 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 736 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 737 Uri _getUri(uri) { | 737 Uri _getUri(uri) { |
| 738 if (uri is Uri) return uri; | 738 if (uri is Uri) return uri; |
| 739 return Uri.parse(uri); | 739 return Uri.parse(uri); |
| 740 } | 740 } |
| OLD | NEW |