Skip to content

Commit ddfde57

Browse files
tvolkertcommit-bot@chromium.org
authored andcommitted
Update File.openRead to return Stream<Uint8List>
Bug: #36900 Change-Id: Ib2e417f4baa0048e2d4c2156c250d0cf454fdf87 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104523 Commit-Queue: Todd Volkert <[email protected]> Reviewed-by: Lasse R.H. Nielsen <[email protected]>
1 parent c92af46 commit ddfde57

23 files changed

Lines changed: 58 additions & 26 deletions

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ vars = {
8585
"fixnum_tag": "0.10.9",
8686
"glob_tag": "1.1.7",
8787
"html_tag" : "0.14.0+1",
88-
"http_io_rev": "773f4bc73ef572e2c37e879b065c3b406d75e8fd",
88+
"http_io_rev": "0b05781c273a040ef521b5f7771dbc0356305872",
8989
"http_multi_server_tag" : "2.0.5",
9090
"http_parser_tag" : "3.1.3",
9191
"http_retry_tag": "0.1.1",

pkg/analysis_server/benchmark/integration/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Stream<Operation> openInput(PerfArgs args) {
121121
}
122122
logger.log(Level.INFO, 'tmpSrcDir: ${args.tmpSrcDirPath}');
123123
return inputRaw
124+
.cast<List<int>>()
124125
.transform(systemEncoding.decoder)
125126
.transform(new LineSplitter())
126127
.transform(new InputConverter(args.tmpSrcDirPath, args.srcPathMap));

pkg/front_end/lib/src/fasta/parser/parser_main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ mainEntryPoint(List<String> arguments) async {
3636
Uri uri = Uri.base.resolve(argument.substring(1));
3737
await for (String file in new File.fromUri(uri)
3838
.openRead()
39+
.cast<List<int>>()
3940
.transform(utf8.decoder)
4041
.transform(const LineSplitter())) {
4142
outLine(uri.resolve(file));

pkg/test_runner/lib/src/multitest.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Future<List<TestFile>> splitMultitest(
195195
// want to copy the permissions, so we create the copy by writing.
196196
final source = File(sourceDir.join(importPath).toNativePath()).openRead();
197197
final target = File(targetDir.join(importPath).toNativePath()).openWrite();
198-
futureCopies.add(source.pipe(target));
198+
futureCopies.add(source.cast<List<int>>().pipe(target));
199199
}
200200

201201
// Wait until all imports are copied before scheduling test cases.

pkg/test_runner/lib/src/testing_servers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class TestingServers {
373373
response.headers.set('Content-Type', 'text/xml');
374374
}
375375
response.headers.removeAll("X-Frame-Options");
376-
file.openRead().pipe(response).catchError((e) {
376+
file.openRead().cast<List<int>>().pipe(response).catchError((e) {
377377
DebugLogger.warning(
378378
'HttpServer: error while closing the response stream', e);
379379
});

pkg/testing/lib/src/test_dart/status_file_parser.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ void ReadConfigurationInto(Path path, List<Section> sections, void onDone()) {
8282
throw new Exception('Cannot find test status file $path');
8383
}
8484
int lineNumber = 0;
85-
Stream<String> lines =
86-
file.openRead().transform(utf8.decoder).transform(new LineSplitter());
85+
Stream<String> lines = file
86+
.openRead()
87+
.cast<List<int>>()
88+
.transform(utf8.decoder)
89+
.transform(new LineSplitter());
8790

8891
Section currentSection = new Section.always(statusFile, -1);
8992
sections.add(currentSection);

pkg/vm/bin/run_binary_size_analysis.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $ google-chrome <output-directory>/index.html
3939
// a tree.
4040
final symbols = await input
4141
.openRead()
42+
.cast<List<int>>()
4243
.transform(utf8.decoder)
4344
.transform(json.decoder)
4445
.first;

runtime/tests/vm/dart/v8_snapshot_profile_writer_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ testMacros(String sdkRoot) async {
113113

114114
await for (String line in File(rawObjectFieldsPath)
115115
.openRead()
116+
.cast<List<int>>()
116117
.transform(utf8.decoder)
117118
.transform(LineSplitter())) {
118119
Match match = matchComplete(fieldEntry, line);
@@ -133,6 +134,7 @@ testMacros(String sdkRoot) async {
133134
bool hasMissingFields = false;
134135
await for (String line in File(rawObjectPath)
135136
.openRead()
137+
.cast<List<int>>()
136138
.transform(utf8.decoder)
137139
.transform(LineSplitter())) {
138140
Match match = matchComplete(classStart, line);

sdk/lib/io/file.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ abstract class File implements FileSystemEntity {
483483
* must be read to completion or the subscription on the stream must
484484
* be cancelled.
485485
*/
486-
Stream<List<int>> openRead([int start, int end]);
486+
Stream<Uint8List> openRead([int start, int end]);
487487

488488
/**
489489
* Creates a new independent [IOSink] for the file. The

sdk/lib/io/file_impl.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ part of dart.io;
77
// Read the file in blocks of size 64k.
88
const int _blockSize = 64 * 1024;
99

10-
class _FileStream extends Stream<List<int>> {
10+
class _FileStream extends Stream<Uint8List> {
1111
// Stream controller.
12-
StreamController<List<int>> _controller;
12+
StreamController<Uint8List> _controller;
1313

1414
// Information about the underlying file.
1515
String _path;
@@ -33,15 +33,15 @@ class _FileStream extends Stream<List<int>> {
3333

3434
_FileStream.forStdin() : _position = 0;
3535

36-
StreamSubscription<List<int>> listen(void onData(List<int> event),
36+
StreamSubscription<Uint8List> listen(void onData(Uint8List event),
3737
{Function onError, void onDone(), bool cancelOnError}) {
3838
_setupController();
3939
return _controller.stream.listen(onData,
4040
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
4141
}
4242

4343
void _setupController() {
44-
_controller = new StreamController<List<int>>(
44+
_controller = new StreamController<Uint8List>(
4545
sync: true,
4646
onListen: _start,
4747
onResume: _readBlock,
@@ -498,7 +498,7 @@ class _File extends FileSystemEntity implements File {
498498
return new _RandomAccessFile(id, "");
499499
}
500500

501-
Stream<List<int>> openRead([int start, int end]) {
501+
Stream<Uint8List> openRead([int start, int end]) {
502502
return new _FileStream(path, start, end);
503503
}
504504

0 commit comments

Comments
 (0)