The file NUL
does not exist on Windows
#15019
Labels
kind:bug
A bug in the code. Does not apply to documentation, specs, etc.
topic:stdlib:files
topic:stdlib:system
On Windows, it is possible to query the null device
File::NULL = "NUL"
's info, or open it:But
File.exists?("NUL")
returns false. This somewhat contradictory result occurs for all special DOS device names, likeCOM1
,AUX
, andCONOUT$
.File::Info.readable?
and.writable?
also have this issue.The difference between the two is that the former calls
CreateFileW
whereas the latter callsGetFileAttributesW
. Ruby works sinceFile.exist?
there returns true if and only if a platform-specificstat
call succeeded; on Windows, thisstat
ultimately callsCreateFileW
first.This affects
File.realpath
too, as it internally callsCrystal::System::File.exists?
. Ideally that should return\\.\NUL
, a special path under the Win32 device namespace.The text was updated successfully, but these errors were encountered: