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

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

Issue 12382031: Make pub warning-clean. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | utils/pub/log.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) 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 } 182 }
183 }, 183 },
184 onDone: () { 184 onDone: () {
185 // TODO(rnystrom): May need to sort here if it turns out 185 // TODO(rnystrom): May need to sort here if it turns out
186 // onDir and onFile aren't guaranteed to be called in a 186 // onDir and onFile aren't guaranteed to be called in a
187 // certain order. So far, they seem to. 187 // certain order. So far, they seem to.
188 log.fine("Listed directory $dir:\n${contents.join('\n')}"); 188 log.fine("Listed directory $dir:\n${contents.join('\n')}");
189 completer.complete(contents); 189 completer.complete(contents);
190 }, 190 },
191 onError: (error) => completer.completeError(error, stackTrace)); 191 onError: (error) => completer.completeError(error));
192 192
193 return completer.future.then((contents) { 193 return completer.future.then((contents) {
194 return Future.wait(children).then((childContents) { 194 return Future.wait(children).then((childContents) {
195 contents.addAll(flatten(childContents)); 195 contents.addAll(flatten(childContents));
196 return contents; 196 return contents;
197 }); 197 });
198 }); 198 });
199 } 199 }
200 200
201 return doList(dir, new Set<String>()); 201 return doList(dir, new Set<String>());
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 completer.completeError(new TimeoutException( 598 completer.completeError(new TimeoutException(
599 'Timed out while $description.')); 599 'Timed out while $description.'));
600 }); 600 });
601 input.then((value) { 601 input.then((value) {
602 if (completed) return; 602 if (completed) return;
603 timer.cancel(); 603 timer.cancel();
604 completer.complete(value); 604 completer.complete(value);
605 }).catchError((e) { 605 }).catchError((e) {
606 if (completed) return; 606 if (completed) return;
607 timer.cancel(); 607 timer.cancel();
608 completer.completeError(e.error, e.stackTrace); 608 completer.completeError(e);
609 }); 609 });
610 return completer.future; 610 return completer.future;
611 } 611 }
612 612
613 /// Creates a temporary directory and passes its path to [fn]. Once the [Future] 613 /// Creates a temporary directory and passes its path to [fn]. Once the [Future]
614 /// returned by [fn] completes, the temporary directory and all its contents 614 /// returned by [fn] completes, the temporary directory and all its contents
615 /// will be deleted. 615 /// will be deleted.
616 /// 616 ///
617 /// Returns a future that completes to the value that the future returned from 617 /// Returns a future that completes to the value that the future returned from
618 /// [fn] completes to. 618 /// [fn] completes to.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 }); 709 });
710 }); 710 });
711 } 711 }
712 712
713 /// Create a .tar.gz archive from a list of entries. Each entry can be a 713 /// Create a .tar.gz archive from a list of entries. Each entry can be a
714 /// [String], [Directory], or [File] object. The root of the archive is 714 /// [String], [Directory], or [File] object. The root of the archive is
715 /// considered to be [baseDir], which defaults to the current working directory. 715 /// considered to be [baseDir], which defaults to the current working directory.
716 /// Returns a [ByteStream] that will emit the contents of the archive. 716 /// Returns a [ByteStream] that will emit the contents of the archive.
717 ByteStream createTarGz(List contents, {baseDir}) { 717 ByteStream createTarGz(List contents, {baseDir}) {
718 var buffer = new StringBuffer(); 718 var buffer = new StringBuffer();
719 buffer.add('Creating .tag.gz stream containing:\n'); 719 buffer.write('Creating .tag.gz stream containing:\n');
720 contents.forEach((file) => buffer.add('$file\n')); 720 contents.forEach((file) => buffer.write('$file\n'));
721 log.fine(buffer.toString()); 721 log.fine(buffer.toString());
722 722
723 var controller = new StreamController<List<int>>(); 723 var controller = new StreamController<List<int>>();
724 724
725 if (baseDir == null) baseDir = path.current; 725 if (baseDir == null) baseDir = path.current;
726 baseDir = path.absolute(baseDir); 726 baseDir = path.absolute(baseDir);
727 contents = contents.map((entry) { 727 contents = contents.map((entry) {
728 entry = path.absolute(entry); 728 entry = path.absolute(entry);
729 if (!isBeneath(entry, baseDir)) { 729 if (!isBeneath(entry, baseDir)) {
730 throw 'Entry $entry is not inside $baseDir.'; 730 throw 'Entry $entry is not inside $baseDir.';
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 const PubProcessResult(this.stdout, this.stderr, this.exitCode); 804 const PubProcessResult(this.stdout, this.stderr, this.exitCode);
805 805
806 bool get success => exitCode == 0; 806 bool get success => exitCode == 0;
807 } 807 }
808 808
809 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. 809 /// Gets a [Uri] for [uri], which can either already be one, or be a [String].
810 Uri _getUri(uri) { 810 Uri _getUri(uri) {
811 if (uri is Uri) return uri; 811 if (uri is Uri) return uri;
812 return Uri.parse(uri); 812 return Uri.parse(uri);
813 } 813 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/log.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698