Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: pkg/front_end/lib/src/fasta/scanner/io.dart

Issue 2827543006: Make zero-termination optional. (Closed)
Patch Set: Minor problems found during testing. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/io.dart ('k') | pkg/front_end/lib/src/fasta/translate_uri.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/scanner/io.dart
diff --git a/pkg/front_end/lib/src/fasta/scanner/io.dart b/pkg/front_end/lib/src/fasta/scanner/io.dart
index 132eea1bab624d6d6cbe25117b29cdfc608c2aa0..8fdbe2366d77fe8d186ac3efbeb0315f93d67c1f 100644
--- a/pkg/front_end/lib/src/fasta/scanner/io.dart
+++ b/pkg/front_end/lib/src/fasta/scanner/io.dart
@@ -24,13 +24,14 @@ List<int> readBytesFromFileSync(Uri uri) {
return list;
}
-Future<List<int>> readBytesFromFile(Uri uri) async {
+Future<List<int>> readBytesFromFile(Uri uri,
+ {bool ensureZeroTermination: true}) async {
RandomAccessFile file = await new File.fromUri(uri).open();
Uint8List list;
try {
int length = await file.length();
// +1 to have a 0 terminated list, see [Scanner].
- list = new Uint8List(length + 1);
+ list = new Uint8List(ensureZeroTermination ? length + 1 : length);
int read = await file.readInto(list);
if (read != length) {
throw "Error reading file: ${uri}";
« no previous file with comments | « pkg/front_end/lib/src/fasta/io.dart ('k') | pkg/front_end/lib/src/fasta/translate_uri.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698