Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RandomAccessFile missing documentation on EOF #50034

Closed
gaaclarke opened this issue Sep 22, 2022 · 3 comments
Closed

RandomAccessFile missing documentation on EOF #50034

gaaclarke opened this issue Sep 22, 2022 · 3 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.

Comments

@gaaclarke
Copy link
Contributor

The following methods don't state the behavior when reading reaches EOF:

@mraleph mraleph added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Sep 23, 2022
@mraleph
Copy link
Member

mraleph commented Sep 23, 2022

/cc @brianquinlan

@Levi-Lesches
Copy link

Levi-Lesches commented Sep 29, 2023

Based on my tests, it seems like it truncates:

import "dart:io";

/// Re-open the file to read the _entire_ file each time
Future<void> readFile(int test, int len) async {
  final file = await File("temp.txt").open();
  final buffer = await file.read(len);
  print("Test $test: Read ${buffer.length} bytes");
}

Future<void> main() async {
  final length = await File("temp.txt").length();
  print("The file is $length bytes long");
  await readFile(1, length);
  await readFile(2, length + 10);
  await readFile(3, length - 10);
}

Output:

The file is 24 bytes long
Test 1: Read 24 bytes
Test 2: Read 24 bytes
Test 3: Read 14 bytes

@brianquinlan brianquinlan self-assigned this Sep 29, 2023
@notcancername
Copy link

Dart 3 documentation also doesn't specify short read behavior.

copybara-service bot pushed a commit that referenced this issue Sep 29, 2023
…ested bytes

Bug:#50034
Change-Id: Ib2f2b11bc3ae1fe241b71a43f2866233e066d8e2
CoreLibraryReviewExempt: Documentation-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328802
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
Projects
None yet
Development

No branches or pull requests

5 participants