From 7f78cb1ab0d6ed26fe0ca519177499c8cb54b397 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Jun 2025 10:42:25 -0700 Subject: [PATCH 1/3] Add a test to verify that virtual files can be written to --- pkgs/io_file/test/write_as_bytes_test.dart | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/io_file/test/write_as_bytes_test.dart b/pkgs/io_file/test/write_as_bytes_test.dart index b7e2ab91..8b1e6ae2 100644 --- a/pkgs/io_file/test/write_as_bytes_test.dart +++ b/pkgs/io_file/test/write_as_bytes_test.dart @@ -180,6 +180,26 @@ 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('console', () { + final data = 'Hello World\n'.codeUnits; + + fileSystem.writeAsBytes( + Platform.isWindows ? r'\\.\CON' : '/dev/tty', + Uint8List.fromList(data), + WriteMode.appendExisting, + ); + }); + test('failExisting', () { final data = randomUint8List(20); final path = '$tmp/file'; From 7e14980d966ebd2a9406735b7d0ca385df9b8a22 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Jun 2025 10:44:15 -0700 Subject: [PATCH 2/3] Update example --- pkgs/io_file/lib/src/file_system.dart | 4 ++-- pkgs/io_file/lib/src/vm_windows_file_system.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/io_file/lib/src/file_system.dart b/pkgs/io_file/lib/src/file_system.dart index 289f6f43..bf8827a8 100644 --- a/pkgs/io_file/lib/src/file_system.dart +++ b/pkgs/io_file/lib/src/file_system.dart @@ -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. diff --git a/pkgs/io_file/lib/src/vm_windows_file_system.dart b/pkgs/io_file/lib/src/vm_windows_file_system.dart index 9f5453eb..0fdb8ed6 100644 --- a/pkgs/io_file/lib/src/vm_windows_file_system.dart +++ b/pkgs/io_file/lib/src/vm_windows_file_system.dart @@ -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) { From abd736010e83223155b911b48ea75f9d57166632 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 30 Jun 2025 10:58:18 -0700 Subject: [PATCH 3/3] Update write_as_bytes_test.dart --- pkgs/io_file/test/write_as_bytes_test.dart | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pkgs/io_file/test/write_as_bytes_test.dart b/pkgs/io_file/test/write_as_bytes_test.dart index 8b1e6ae2..93851466 100644 --- a/pkgs/io_file/test/write_as_bytes_test.dart +++ b/pkgs/io_file/test/write_as_bytes_test.dart @@ -190,16 +190,6 @@ void main() { ); }); - test('console', () { - final data = 'Hello World\n'.codeUnits; - - fileSystem.writeAsBytes( - Platform.isWindows ? r'\\.\CON' : '/dev/tty', - Uint8List.fromList(data), - WriteMode.appendExisting, - ); - }); - test('failExisting', () { final data = randomUint8List(20); final path = '$tmp/file';