Comments (4)
@driver1998 They do not mean anything outside Win32. Within Win32, they're not limited to command line apps.
The reason that NUL doesn't do anything is because it's the null device (equivalent to /dev/null
in *nix parlance). If you try type con
, it echos the console input. If you try type con >prn
, it copies console input to the printer.
The reason that you can access these files using \\.\
is detailed in the aforementioned documentation ("Win32 Device Namespqces"), because it doesn't try to resolve predefine aliases, and the call to \\.\d:\test\nul
is accessing the device driver implementing D:
namespace (which happen to be file system).
The bottom line is that one can always create files with reserved names, but it's not going to play well with the vast majority of Win32 programs. For old-timers, the need of these special handlings arises from compatibility requirements. For newer programs, one can regard the need of using \\.\
syntax as an explicit request to opt of the usual behavior in danger of making a mess.
from windows-dev-performance.
Sorry - this is a 30+ year old platform limitation with wide-ranging compatibility issues.
from windows-dev-performance.
- Do not use the following reserved names for the name of a file:
CON
,PRN
,AUX
,NUL
,COM1
,COM2
,COM3
,COM4
,COM5
,COM6
,COM7
,COM8
,COM9
,LPT1
,LPT2
,LPT3
,LPT4
,LPT5
,LPT6
,LPT7
,LPT8
, andLPT9
. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended. - Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example,
.temp
.
From a Raymond Chen blogspot (2003):
Why do these magic files exist in every directory?
Answer: Because DOS 1.0 didn’t have subdirectories. There was only one directory, which today we would call the root directory, but back then, since there was no such thing as a subdirectory, there was no need to talk about directories in the first place, much less give the only one you have a name. It was just called “the files on your disk”. If magic files didn’t work in subdirectories, then when you tried to, for example, chdir into a subdirectory and then run the assembler, you wouldn’t be able to type “NUL” as the filename and get the magic.
from windows-dev-performance.
Do these files actually mean anything outside of Win32 command line apps (or more specifically, CMD)? Most of the time they are just "reserved" and doesn't do anything.
And this limitation only exists on Win32 subsystem, you can easily create a file named NUL or CON in WSL, heck you can even open them in a Win32 app using UNC path.
from windows-dev-performance.
Related Issues (20)
- PROCESSOR_POWER_INFORMATION.CurrentMhz no longer shows CurrentMhz HOT 7
- Throttling detection needed in Windows HOT 5
- Symbol server PE files are being overwritten with different versions HOT 13
- WinDbg's `dU` command is painfully slow HOT 4
- Merge module validation in Orca fails on well-formed merge module
- NT heap scales horrendously in some cases HOT 2
- Set up your dev environment on Windows for Rust HOT 2
- PrefetchVirtualMemory does not prefetch virtual memory (windows api bug) HOT 1
- Explorer leaks resources over a long time HOT 2
- Configuring RDP with MSA is impossible using the RDP Developer Menu HOT 1
- Argon containers use only weak cores on systems with heterogeneous CPUs HOT 4
- Extremely slow Context Menu launch in Windows Explorer HOT 2
- Unexpected Sleep(1) Precision with Different Clock Interrupt Frequencies (Timer Resolution) HOT 3
- Dev drive has vanished HOT 3
- Windows incorrectly schedules utility QoS threads exclusively to E-cores when running on AC power
- Alt + Tab Sometimes Skips over the Last Window
- Alt+tab issue when in full-screen app HOT 2
- Can't Pinpoint What to do with Error PR175 with Visual Studio HOT 2
- "Must define a target architecture" issue from winnt.h when included by `.rc` files HOT 7
- Consistent CPU performance for benchmarking HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windows-dev-performance.