Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: utils/pub/io.dart

Issue 14070010: Refactor Future constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added co19 issue number. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/pub/hosted_source.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « utils/pub/hosted_source.dart ('k') | utils/pub/oauth2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698