Skip to content

Commit 8c59f9a

Browse files
authored
Add a test to verify that virtual files can be written to (#251)
1 parent dcdc798 commit 8c59f9a

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pkgs/io_file/lib/src/file_system.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ class WriteMode {
137137
/// On Windows, paths refering to objects in the
138138
/// [win32 device namespace](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces),
139139
/// such as named pipes, physical disks, and serial comnmunications ports
140-
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'COM1'` would
141-
/// be refered to by the path `r'\\.\COM1'`.
140+
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'NUL'` would
141+
/// be refered to by the path `r'\\.\NUL'`.
142142
@sealed
143143
abstract class FileSystem {
144144
/// Create a directory at the given path.

pkgs/io_file/lib/src/vm_windows_file_system.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,8 @@ final class WindowsMetadata implements Metadata {
331331
/// On Windows, paths refering to objects in the
332332
/// [win32 device namespace](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-device-namespaces),
333333
/// such as named pipes, physical disks, and serial comnmunications ports
334-
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'COM1'` would
335-
/// be refered to by the path `r'\\.\COM1'`.
334+
/// (e.g. 'COM1'), must be prefixed with `r'\\.\'`. For example, `'NUL'` would
335+
/// be refered to by the path `r'\\.\NUL'`.
336336
final class WindowsFileSystem extends FileSystem {
337337
@override
338338
bool same(String path1, String path2) => using((arena) {

pkgs/io_file/test/write_as_bytes_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ void main() {
180180
expect(File(path).readAsBytesSync(), [1, 2, 3] + data);
181181
});
182182

183+
test('null file', () {
184+
final data = randomUint8List(20);
185+
186+
fileSystem.writeAsBytes(
187+
Platform.isWindows ? r'\\.\NUL' : '/dev/null',
188+
Uint8List.fromList(data),
189+
WriteMode.appendExisting,
190+
);
191+
});
192+
183193
test('failExisting', () {
184194
final data = randomUint8List(20);
185195
final path = '$tmp/file';

0 commit comments

Comments
 (0)