OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.util.io; | 5 library test.util.io; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 /// Return a transformation of [input] with all null bytes removed. | 110 /// Return a transformation of [input] with all null bytes removed. |
111 /// | 111 /// |
112 /// This works around the combination of issue 23295 and 22667 by removing null | 112 /// This works around the combination of issue 23295 and 22667 by removing null |
113 /// bytes. This workaround can be removed when either of those are fixed in the | 113 /// bytes. This workaround can be removed when either of those are fixed in the |
114 /// oldest supported SDK. | 114 /// oldest supported SDK. |
115 /// | 115 /// |
116 /// It also somewhat works around issue 23303 by removing any carriage returns | 116 /// It also somewhat works around issue 23303 by removing any carriage returns |
117 /// that are followed by newlines, to ensure that carriage returns aren't | 117 /// that are followed by newlines, to ensure that carriage returns aren't |
118 /// doubled up in the output. This can be removed when the issue is fixed in the | 118 /// doubled up in the output. This can be removed when the issue is fixed in the |
119 /// oldest supported SDk. | 119 /// oldest supported SDk. |
120 Stream<List<int>> santizeForWindows(Stream<List<int>> input) { | 120 Stream<List<int>> sanitizeForWindows(Stream<List<int>> input) { |
121 if (!Platform.isWindows) return input; | 121 if (!Platform.isWindows) return input; |
122 | 122 |
123 return input.map((list) { | 123 return input.map((list) { |
124 var previous; | 124 var previous; |
125 return list.reversed.where((byte) { | 125 return list.reversed.where((byte) { |
126 if (byte == 0) return false; | 126 if (byte == 0) return false; |
127 if (byte == _carriageReturn && previous == _newline) return false; | 127 if (byte == _carriageReturn && previous == _newline) return false; |
128 previous = byte; | 128 previous = byte; |
129 return true; | 129 return true; |
130 }).toList().reversed.toList(); | 130 }).toList().reversed.toList(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 /// returned. | 168 /// returned. |
169 String libraryPath(Symbol libraryName, {String packageRoot}) { | 169 String libraryPath(Symbol libraryName, {String packageRoot}) { |
170 var lib = currentMirrorSystem().findLibrary(libraryName); | 170 var lib = currentMirrorSystem().findLibrary(libraryName); |
171 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); | 171 if (lib.uri.scheme != 'package') return p.fromUri(lib.uri); |
172 | 172 |
173 // TODO(nweiz): is there a way to avoid assuming this is being run next to a | 173 // TODO(nweiz): is there a way to avoid assuming this is being run next to a |
174 // packages directory?. | 174 // packages directory?. |
175 if (packageRoot == null) packageRoot = p.absolute('packages'); | 175 if (packageRoot == null) packageRoot = p.absolute('packages'); |
176 return p.join(packageRoot, p.fromUri(lib.uri.path)); | 176 return p.join(packageRoot, p.fromUri(lib.uri.path)); |
177 } | 177 } |
OLD | NEW |