Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Cannot open special Windows device "NUL" #9271

Closed
natevw opened this issue Feb 23, 2015 · 2 comments
Closed

Cannot open special Windows device "NUL" #9271

natevw opened this issue Feb 23, 2015 · 2 comments

Comments

@natevw
Copy link

natevw commented Feb 23, 2015

I can't figure out a way to fs.openSync("NUL") (the Win32 equivalent of "/dev/null").

It seems that, since the open logic resolves to absolute path first, rather than just passing what I provide to the underlying call, that any special files like this will fail under Windows.

@natevw
Copy link
Author

natevw commented Feb 23, 2015

Figured it out via this post: fs.open("\\\\.\\NUL", "r") works.

Whether this is a workaround or the expected "right" way to accomplish this I don't know, but it works.

@OrangeDog
Copy link

That's the correct UNC path for a device file.

https://msdn.microsoft.com/en-gb/library/windows/desktop/aa365247.aspx#Win32_Device_Namespaces

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants