-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: os.DirFS doesn't work with Windows UNC paths #54694
Comments
@PatrLind Can you try replacing |
Change https://go.dev/cl/425876 mentions this issue: |
see also #44279 |
@rsc @iant, not sure what the best plan here is. The fix recommended in https://go.dev/cl/425876 seems to not be enough. |
We can't import path/filepath but the functions being used are trivial, so let's just copy them into the os package. Only not literally because "os" shouldn't import "strings" either. Does https://go.dev/cl/426094 fix the problem? |
Change https://go.dev/cl/426094 mentions this issue: |
I think it is a feasible and good solution. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?I build on Linux and run on Windows (Microsoft Windows [Version 10.0.19044.1889])
go env
OutputWhat did you do?
I created a test program that tries to walk the root dir. I test it with a normal path and also a UNC path.
The program gives the expected output on Linux using wine, but on a real Windows machine it doesn't work.
I created my own "fixed" implementation of os.DirFS that seems to solve the issue.
What did you expect to see?
I expected the UNC path with fs.WalkDir() to work.
What did you see instead?
It gives me an error:
CreateFile \\?\C:\/.: The filename, directory name, or volume label syntax is incorrect.
Seems like Windows doesn't like forward slashes in UNC paths.
Suggested fix
I think the os.DirFS implementation should convert the forward style slashes of the fs.FS implementation to platform native path separators before sending the function calls off to the os.Open() and os.Stat().
The text was updated successfully, but these errors were encountered: