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) { diff --git a/pkgs/io_file/test/write_as_bytes_test.dart b/pkgs/io_file/test/write_as_bytes_test.dart index b7e2ab91..93851466 100644 --- a/pkgs/io_file/test/write_as_bytes_test.dart +++ b/pkgs/io_file/test/write_as_bytes_test.dart @@ -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';