| 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 /// 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ..closeSync(); | 74 ..closeSync(); |
| 75 log.fine("Wrote text file $file."); | 75 log.fine("Wrote text file $file."); |
| 76 return file; | 76 return file; |
| 77 } | 77 } |
| 78 | 78 |
| 79 /// Writes [stream] to a new file at path [file]. Will replace any file already | 79 /// Writes [stream] to a new file at path [file]. Will replace any file already |
| 80 /// at that path. Completes when the file is done being written. | 80 /// at that path. Completes when the file is done being written. |
| 81 Future<String> createFileFromStream(Stream<List<int>> stream, String file) { | 81 Future<String> createFileFromStream(Stream<List<int>> stream, String file) { |
| 82 log.io("Creating $file from stream."); | 82 log.io("Creating $file from stream."); |
| 83 | 83 |
| 84 var stream = new File(file).openOutputStream(); | 84 var outputStream = new File(file).openOutputStream(); |
| 85 return stream.pipe(wrapOutputStream(stream)).then((_) { | 85 return stream.pipe(wrapOutputStream(outputStream)).then((_) { |
| 86 log.fine("Created $file from stream."); | 86 log.fine("Created $file from stream."); |
| 87 return file; | 87 return file; |
| 88 }); | 88 }); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /// Creates a directory [dir]. | 91 /// Creates a directory [dir]. |
| 92 String createDir(String dir) { | 92 String createDir(String dir) { |
| 93 new Directory(dir).createSync(); | 93 new Directory(dir).createSync(); |
| 94 return dir; | 94 return dir; |
| 95 } | 95 } |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 860 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
| 861 | 861 |
| 862 bool get success => exitCode == 0; | 862 bool get success => exitCode == 0; |
| 863 } | 863 } |
| 864 | 864 |
| 865 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 865 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 866 Uri _getUri(uri) { | 866 Uri _getUri(uri) { |
| 867 if (uri is Uri) return uri; | 867 if (uri is Uri) return uri; |
| 868 return Uri.parse(uri); | 868 return Uri.parse(uri); |
| 869 } | 869 } |
| OLD | NEW |