Skip to content

[breaking change] On Windows refer to special null file as '\\?\nul' rather than 'nul'. #56308

Open
@aam

Description

@aam

Change Intent

We want to consistently canonicalize all file names using Windows API so that all file, directory operations can consistently enjoy 32k-file name limit.
Caveat of using that API is that it treats nul as regular file name and one has to use \\?\nul to refer to this special file. In posix it's equivalent of '/dev/null'.

So here is the proposal to make this change in dart: File('NUL').writeAsBytesSync(bytes); becomes File(r'\\?\NUL').writeAsBytesSync(bytes);.

Justification

Windows support for long path names itself is breaking, so if Dart enables developers to use long paths then this breaking change is unavoidable.

Issues that are to be addressed by this change are #56125, #55972

See https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats for details on various windows file name formats.

Impact

This only concerns dart running on Windows. It is expected that use of 'nul' is rare if existent at all.
Existing code that reads from/writes to nul will start throwing because nul will be canonicalized to \\?\UNC\nul - file location that can't be read to or written from.

Mitigation

Code that was reading from or writing to nul will start throwing, have to be changed to refer to \\?\nul.

Change Timeline

There change is already implemented, so it can be submitted as soon as it is approved.

Associated CLs

https://dart-review.git.corp.google.com/c/sdk/+/375421

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.breaking-change-approvedbreaking-change-requestThis tracks requests for feedback on breaking changesos-windowstriagedIssue has been triaged by sub team

    Type

    No type

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions