| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 62 } |
| 63 | 63 |
| 64 new File(file).writeAsStringSync(contents); | 64 new File(file).writeAsStringSync(contents); |
| 65 return file; | 65 return file; |
| 66 } | 66 } |
| 67 | 67 |
| 68 /// Creates [file] and writes [contents] to it. | 68 /// Creates [file] and writes [contents] to it. |
| 69 String writeBinaryFile(String file, List<int> contents) { | 69 String writeBinaryFile(String file, List<int> contents) { |
| 70 log.io("Writing ${contents.length} bytes to binary file $file."); | 70 log.io("Writing ${contents.length} bytes to binary file $file."); |
| 71 new File(file).openSync(mode: FileMode.WRITE) | 71 new File(file).openSync(mode: FileMode.WRITE) |
| 72 ..writeListSync(contents, 0, contents.length) | 72 ..writeFromSync(contents) |
| 73 ..closeSync(); | 73 ..closeSync(); |
| 74 log.fine("Wrote text file $file."); | 74 log.fine("Wrote text file $file."); |
| 75 return file; | 75 return file; |
| 76 } | 76 } |
| 77 | 77 |
| 78 /// Writes [stream] to a new file at path [file]. Will replace any file already | 78 /// Writes [stream] to a new file at path [file]. Will replace any file already |
| 79 /// at that path. Completes when the file is done being written. | 79 /// at that path. Completes when the file is done being written. |
| 80 Future<String> createFileFromStream(Stream<List<int>> stream, String file) { | 80 Future<String> createFileFromStream(Stream<List<int>> stream, String file) { |
| 81 log.io("Creating $file from stream."); | 81 log.io("Creating $file from stream."); |
| 82 | 82 |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 const PubProcessResult(this.stdout, this.stderr, this.exitCode); | 731 const PubProcessResult(this.stdout, this.stderr, this.exitCode); |
| 732 | 732 |
| 733 bool get success => exitCode == 0; | 733 bool get success => exitCode == 0; |
| 734 } | 734 } |
| 735 | 735 |
| 736 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 736 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 737 Uri _getUri(uri) { | 737 Uri _getUri(uri) { |
| 738 if (uri is Uri) return uri; | 738 if (uri is Uri) return uri; |
| 739 return Uri.parse(uri); | 739 return Uri.parse(uri); |
| 740 } | 740 } |
| OLD | NEW |