| 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 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
| 6 library pub.utils; | 6 library pub.utils; |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 completed = true; | 65 completed = true; |
| 66 _completer.completeError(e); | 66 _completer.completeError(e); |
| 67 })); | 67 })); |
| 68 | 68 |
| 69 return task; | 69 return task; |
| 70 } | 70 } |
| 71 | 71 |
| 72 Future<List> get future => _completer.future; | 72 Future<List> get future => _completer.future; |
| 73 } | 73 } |
| 74 | 74 |
| 75 /// Returns [posix] on POSIX machines and [windows] on Windows. |
| 76 /// |
| 77 /// If [windows] is omitted, returns `""` on Windows. |
| 78 String getPlatformString(String posix, [String windows]) { |
| 79 if (windows == null) windows = ""; |
| 80 return Platform.operatingSystem == "windows" ? windows : posix; |
| 81 } |
| 82 |
| 75 /// Like [new Future], but avoids around issue 11911 by using [new Future.value] | 83 /// Like [new Future], but avoids around issue 11911 by using [new Future.value] |
| 76 /// under the covers. | 84 /// under the covers. |
| 77 Future newFuture(callback()) => new Future.value().then((_) => callback()); | 85 Future newFuture(callback()) => new Future.value().then((_) => callback()); |
| 78 | 86 |
| 79 // TODO(rnystrom): Move into String? | 87 // TODO(rnystrom): Move into String? |
| 80 /// Pads [source] to [length] by adding spaces at the end. | 88 /// Pads [source] to [length] by adding spaces at the end. |
| 81 String padRight(String source, int length) { | 89 String padRight(String source, int length) { |
| 82 final result = new StringBuffer(); | 90 final result = new StringBuffer(); |
| 83 result.write(source); | 91 result.write(source); |
| 84 | 92 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 error is DirectoryException || | 506 error is DirectoryException || |
| 499 error is FileException || | 507 error is FileException || |
| 500 error is HttpException || | 508 error is HttpException || |
| 501 error is HttpException || | 509 error is HttpException || |
| 502 error is LinkException || | 510 error is LinkException || |
| 503 error is OSError || | 511 error is OSError || |
| 504 error is ProcessException || | 512 error is ProcessException || |
| 505 error is SocketException || | 513 error is SocketException || |
| 506 error is WebSocketException; | 514 error is WebSocketException; |
| 507 } | 515 } |
| OLD | NEW |