| 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 /** | 5 /** |
| 6 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 library io; | 8 library io; |
| 9 | 9 |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 printError( | 366 printError( |
| 367 'Warning: Package "$name" does not have a "lib" directory.'); | 367 'Warning: Package "$name" does not have a "lib" directory.'); |
| 368 } | 368 } |
| 369 | 369 |
| 370 return new Future.immediate(to); | 370 return new Future.immediate(to); |
| 371 } | 371 } |
| 372 }); | 372 }); |
| 373 }); | 373 }); |
| 374 } | 374 } |
| 375 | 375 |
| 376 /// Given [entry] which may be a [String], [File], or [Directory] relative to | 376 /** |
| 377 /// the current working directory, returns its full canonicalized path. | 377 * Given [entry] which may be a [String], [File], or [Directory] relative to |
| 378 String getFullPath(entry) { | 378 * the current working directory, returns its full canonicalized path. |
| 379 var path = new Path(_getPath(entry)); | 379 */ |
| 380 | 380 // TODO(rnystrom): Should this be async? |
| 381 // Don't do anything if it's already absolute. | 381 String getFullPath(entry) => new File(_getPath(entry)).fullPathSync(); |
| 382 if (path.isAbsolute) return path.toNativePath(); | |
| 383 | |
| 384 // Using Path.join here instead of File().fullPathSync() because the former | |
| 385 // does not require an actual file to exist at that path. | |
| 386 return new Path.fromNative(workingDir).join(path).toNativePath(); | |
| 387 } | |
| 388 | 382 |
| 389 // TODO(nweiz): make this configurable | 383 // TODO(nweiz): make this configurable |
| 390 /** | 384 /** |
| 391 * The amount of time in milliseconds to allow HTTP requests before assuming | 385 * The amount of time in milliseconds to allow HTTP requests before assuming |
| 392 * they've failed. | 386 * they've failed. |
| 393 */ | 387 */ |
| 394 final HTTP_TIMEOUT = 30 * 1000; | 388 final HTTP_TIMEOUT = 30 * 1000; |
| 395 | 389 |
| 396 /** | 390 /** |
| 397 * Opens an input stream for a HTTP GET request to [uri], which may be a | 391 * Opens an input stream for a HTTP GET request to [uri], which may be a |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 return new Directory(entry); | 761 return new Directory(entry); |
| 768 } | 762 } |
| 769 | 763 |
| 770 /** | 764 /** |
| 771 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 765 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 772 */ | 766 */ |
| 773 Uri _getUri(uri) { | 767 Uri _getUri(uri) { |
| 774 if (uri is Uri) return uri; | 768 if (uri is Uri) return uri; |
| 775 return new Uri.fromString(uri); | 769 return new Uri.fromString(uri); |
| 776 } | 770 } |
| OLD | NEW |