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

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

Issue 11348288: Get archive creation working on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 8 years 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/io.dart ('k') | utils/tests/pub/pub.status » ('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 /** 5 /**
6 * Generic utility functions. Stuff that should possibly be in core. 6 * Generic utility functions. Stuff that should possibly be in core.
7 */ 7 */
8 library utils; 8 library utils;
9 9
10 import 'dart:crypto'; 10 import 'dart:crypto';
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return false; 116 return false;
117 } 117 }
118 118
119 /** 119 /**
120 * Returns the hex-encoded sha1 hash of [source]. 120 * Returns the hex-encoded sha1 hash of [source].
121 */ 121 */
122 String sha1(String source) => 122 String sha1(String source) =>
123 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes).digest()); 123 CryptoUtils.bytesToHex(new SHA1().update(source.charCodes).digest());
124 124
125 /** 125 /**
126 * Returns a [Future] that completes in [milliSeconds]. 126 * Returns a [Future] that completes in [milliseconds].
127 */ 127 */
128 Future sleep(int milliSeconds) { 128 Future sleep(int milliseconds) {
129 var completer = new Completer(); 129 var completer = new Completer();
130 new Timer(milliSeconds, completer.complete); 130 new Timer(milliseconds, completer.complete);
131 return completer.future; 131 return completer.future;
132 } 132 }
133 133
134 /// Configures [future] so that its result (success or exception) is passed on 134 /// Configures [future] so that its result (success or exception) is passed on
135 /// to [completer]. 135 /// to [completer].
136 void chainToCompleter(Future future, Completer completer) { 136 void chainToCompleter(Future future, Completer completer) {
137 future.handleException((e) { 137 future.handleException((e) {
138 completer.completeException(e, future.stackTrace); 138 completer.completeException(e, future.stackTrace);
139 return true; 139 return true;
140 }); 140 });
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 /// Add all key/value pairs from [source] to [destination], overwriting any 194 /// Add all key/value pairs from [source] to [destination], overwriting any
195 /// pre-existing values. 195 /// pre-existing values.
196 void mapAddAll(Map destination, Map source) => 196 void mapAddAll(Map destination, Map source) =>
197 source.forEach((key, value) => destination[key] = value); 197 source.forEach((key, value) => destination[key] = value);
198 198
199 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes 199 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes
200 /// replacing `+` with ` `. 200 /// replacing `+` with ` `.
201 String urlDecode(String encoded) => 201 String urlDecode(String encoded) =>
202 decodeUriComponent(encoded.replaceAll("+", " ")); 202 decodeUriComponent(encoded.replaceAll("+", " "));
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/tests/pub/pub.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698