filesystems - On my Windows machine, I had a folder with a name of four dots that acted like some kind of rabbit hole - how did that happen?
The folder name was listed in File Explorer with just plain four dots ....
.
When I tried opening it, I came into some kind of endless rabbit hole loop where I opened the exact same folder again and again - I could do this endlessly. Showing the path like C:\ExamplePath\....\....\....\....\....
, etc.
It was hanging my TypeScript compilation in one specific project. It took me more than a year before I found this folder and its related problems, because it was rooted deeply in nested folders. I never expected an issue like this, so I never looked for it.
I couldn't delete the folder the normal way because of the special name. In the end, I could remove it by using the command line and deleting the parent folder with rd /s /q path
.
Afterward, I tried to create the folder again but was unable to do so with both File Explorer and the command line.
In my 20-plus years of using Windows I have never seen this bug before, so I can imagine that it would really be an annoying and confusing problem for amateur users.
Does anyone know how this could have happened and how to reproduce this issue?
Update
For people who are interested: this path was located deep within a TFS folder. So probably TFS uses the bypass method @grawity explained ("Various file managers, archivers, etc")
Did I stumble on a rare TFS bug?
Answer
Win32 doesn't let you create files or folders with names ending in .
– all dots are stripped from the end. Trying to create test.
makes test
appear instead. (This is for compatibility with 8.3 names in old DOS/Win9x era software.)
As a result, whenever you try to access a folder named ....
, its name gets reduced to the empty string, and you're back to the folder you were in before.
The NT kernel, however, does allow such names. There are various mechanisms which bypass filename limitations imposed by Win32 APIs – for example, WSL (Windows Subsystem for Linux) doesn't run on top of Win32 and is unaffected by it. There is also the \\?\
bypass method, a deliberate "backdoor" left in for programs which know what they're doing. Even though you cannot create C:\Example\....\
, you can create \\?\C:\Example\....\
just fine.
Likewise you can delete such directories with rmdir \\?\C:\path\...
from Cmd (I haven't tested with PowerShell yet).
Various file managers, archivers, etc. might use the \\?\
method in order to be able to use longer path names than usual – and by doing so, they're also unaffected by the compatibility code within Win32; they bypass dot stripping, as well as translation of magic filenames like CON
or NUL
.
So it could be that one of your programs:
- always uses
\\?\
to access files, - accidentally tried to create a folder named
....
– but it's not really possible to know for sure after the fact.
Comments
Post a Comment