Skip to content

Add a test to verify that virtual files can be written to #251

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

Merged
merged 3 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/io_file/lib/src/file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class WriteMode {
/// On Windows, paths refering to objects in the
/// [win32 device namespace](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces),
/// such as named pipes, physical disks, and serial comnmunications ports
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'COM1'` would
/// be refered to by the path `r'\\.\COM1'`.
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'NUL'` would
/// be refered to by the path `r'\\.\NUL'`.
@sealed
abstract class FileSystem {
/// Create a directory at the given path.
Expand Down
4 changes: 2 additions & 2 deletions pkgs/io_file/lib/src/vm_windows_file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ final class WindowsMetadata implements Metadata {
/// On Windows, paths refering to objects in the
/// [win32 device namespace](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces),
/// such as named pipes, physical disks, and serial comnmunications ports
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'COM1'` would
/// be refered to by the path `r'\\.\COM1'`.
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'NUL'` would
/// be refered to by the path `r'\\.\NUL'`.
final class WindowsFileSystem extends FileSystem {
@override
bool same(String path1, String path2) => using((arena) {
Expand Down
10 changes: 10 additions & 0 deletions pkgs/io_file/test/write_as_bytes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ void main() {
expect(File(path).readAsBytesSync(), [1, 2, 3] + data);
});

test('null file', () {
final data = randomUint8List(20);

fileSystem.writeAsBytes(
Platform.isWindows ? r'\\.\NUL' : '/dev/null',
Uint8List.fromList(data),
WriteMode.appendExisting,
);
});

test('failExisting', () {
final data = randomUint8List(20);
final path = '$tmp/file';
Expand Down
Loading