Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path prefixed by \\.\ is not normalised on Windows #247

Open
jasagredo opened this issue Jan 8, 2025 · 5 comments
Open

Path prefixed by \\.\ is not normalised on Windows #247

jasagredo opened this issue Jan 8, 2025 · 5 comments

Comments

@jasagredo
Copy link

I don't see this in the haddocks, is it expected?

ghci> System.FilePath.Windows.normalise "\\\\.\\C:/foo.txt"
"\\\\.\\C:/foo.txt"
ghci> System.FilePath.Windows.normalise "C:/foo.txt"
"C:\\foo.txt"
@jasagredo
Copy link
Author

I can confirm the same works with \\?\:

ghci> System.FilePath.normalise "\\\\?\\C:/foo.txt"
"\\\\?\\C:\\foo.txt"
ghci> System.FilePath.normalise "\\\\.\\C:/foo.txt"
"\\\\.\\C:/foo.txt"

Probably because of this:

ghci> System.FilePath.isDrive "\\\\.\\C:\\"
False
ghci> System.FilePath.isDrive "\\\\?\\C:\\"
True
ghci> System.FilePath.splitDrive "\\\\?\\C:/foo.txt"
("\\\\?\\C:/","foo.txt")
ghci> System.FilePath.splitDrive "\\\\.\\C:/foo.txt"
("\\\\.\\","C:/foo.txt")

@hasufell
Copy link
Member

hasufell commented Jan 8, 2025

Those behaviors are a little inconsistent.

\\.\ should be treated mostly the same as \\?\.

But the latter has an interesting property: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#skip-normalization

But as the windows api documentation says, they're still normalized when passed to GetFullPathName. So maybe we should do the same.

But it would be kind of a breaking change.

Sometimes people rely on "bugs". Is this a bug? It's debatable.

@jasagredo
Copy link
Author

My preference would be to treat both the same.

I think at the very least this behavior should be documented in the examples.

It is counterintuitive.

@hasufell
Copy link
Member

I think at the very least this behavior should be documented in the examples.

well, the thing is that it only behaves so by accident and the code doesn't really ensure this properly... so I find it hard to document it, given it's kinda a quirk

I haven't made up my mind yet what the best solution is.

@hasufell
Copy link
Member

@Mistuke any opinions?

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

No branches or pull requests

2 participants