Chromium Code Reviews| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 * | 324 * |
| 325 * Unlike [createSymlink], this has heuristics to detect if [from] is using | 325 * Unlike [createSymlink], this has heuristics to detect if [from] is using |
| 326 * the old or new style of package layout. If it's using the new style, then | 326 * the old or new style of package layout. If it's using the new style, then |
| 327 * it will create a symlink to the "lib" directory contained inside that | 327 * it will create a symlink to the "lib" directory contained inside that |
| 328 * package directory. Otherwise, it just symlinks to the package directory | 328 * package directory. Otherwise, it just symlinks to the package directory |
| 329 * itself. | 329 * itself. |
| 330 */ | 330 */ |
| 331 // TODO(rnystrom): Remove this when old style packages are no longer supported. | 331 // TODO(rnystrom): Remove this when old style packages are no longer supported. |
| 332 // See: http://code.google.com/p/dart/issues/detail?id=4964. | 332 // See: http://code.google.com/p/dart/issues/detail?id=4964. |
| 333 Future<File> createPackageSymlink(String name, from, to, | 333 Future<File> createPackageSymlink(String name, from, to, |
| 334 [bool isSelfLink = false]) { | 334 {bool isSelfLink: false}) { |
| 335 // If from contains any Dart files at the top level (aside from build.dart) | 335 // If from contains any Dart files at the top level (aside from build.dart) |
| 336 // we assume that means it's an old style package. | 336 // we assume that means it's an old style package. |
| 337 return listDir(from).chain((contents) { | 337 return listDir(from).chain((contents) { |
| 338 var isOldStyle = contents.some( | 338 var isOldStyle = contents.some( |
| 339 (file) => file.endsWith('.dart') && basename(file) != 'build.dart'); | 339 (file) => file.endsWith('.dart') && basename(file) != 'build.dart'); |
| 340 | 340 |
| 341 if (isOldStyle) { | 341 if (isOldStyle) { |
| 342 if (isSelfLink) { | 342 if (isSelfLink) { |
| 343 printError('Warning: Package "$name" is using a deprecated layout.'); | 343 printError('Warning: Package "$name" is using a deprecated layout.'); |
| 344 printError('See http://www.dartlang.org/docs/pub-package-manager/' | 344 printError('See http://www.dartlang.org/docs/pub-package-manager/' |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 .transform((bytes) => new String.fromCharCodes(bytes)); | 442 .transform((bytes) => new String.fromCharCodes(bytes)); |
| 443 return timeout(future, HTTP_TIMEOUT, 'Timed out while fetching URL "$uri".'); | 443 return timeout(future, HTTP_TIMEOUT, 'Timed out while fetching URL "$uri".'); |
| 444 } | 444 } |
| 445 | 445 |
| 446 /** | 446 /** |
| 447 * Takes all input from [source] and writes it to [sink]. | 447 * Takes all input from [source] and writes it to [sink]. |
| 448 * | 448 * |
| 449 * [onClosed] is called when [source] is closed. | 449 * [onClosed] is called when [source] is closed. |
| 450 */ | 450 */ |
| 451 void pipeInputToInput(InputStream source, ListInputStream sink, | 451 void pipeInputToInput(InputStream source, ListInputStream sink, |
| 452 [void onClosed()]) { | 452 {void onClosed()}) { |
|
Bob Nystrom
2012/10/17 16:21:38
Make this positional please.
regis
2012/10/17 19:58:16
Done.
| |
| 453 source.onClosed = () { | 453 source.onClosed = () { |
| 454 sink.markEndOfStream(); | 454 sink.markEndOfStream(); |
| 455 if (onClosed != null) onClosed(); | 455 if (onClosed != null) onClosed(); |
| 456 }; | 456 }; |
| 457 source.onData = () => sink.write(source.read()); | 457 source.onData = () => sink.write(source.read()); |
| 458 // TODO(nweiz): propagate this error to the sink. See issue 3657. | 458 // TODO(nweiz): propagate this error to the sink. See issue 3657. |
| 459 source.onError = (e) { throw e; }; | 459 source.onError = (e) { throw e; }; |
| 460 } | 460 } |
| 461 | 461 |
| 462 /** | 462 /** |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 755 return new Directory(entry); | 755 return new Directory(entry); |
| 756 } | 756 } |
| 757 | 757 |
| 758 /** | 758 /** |
| 759 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 759 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 760 */ | 760 */ |
| 761 Uri _getUri(uri) { | 761 Uri _getUri(uri) { |
| 762 if (uri is Uri) return uri; | 762 if (uri is Uri) return uri; |
| 763 return new Uri.fromString(uri); | 763 return new Uri.fromString(uri); |
| 764 } | 764 } |
| OLD | NEW |