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

Filename.dirname on Win32 UNC paths #7912

vicuna opened this Issue Feb 6, 2019 · 1 comment


None yet
2 participants
Copy link

vicuna commented Feb 6, 2019

Original bug ID: 7912
Reporter: @alainfrisch
Status: new
Resolution: open
Priority: normal
Severity: minor
Category: standard library
Monitored by: @nojb @dbuenzli

Bug description

# let s = "\\\\foo" in Filename.(dirname s, basename s);;
- : string * string = ("\\", "foo")
# let s = "\\\\foo" in Filename.(concat (dirname s) (basename s));;
- : string = "\\foo"

Note that the initial double backslash has been transformed to a single-one, such changing the original path (an absolute one) to a path relative to the current drive. The doc claims that :

If [name] is a valid file name, then [concat (dirname name) (basename name)]
returns a file name which is equivalent to [name].

Technically, \foo is not a valid file name, but it is a valid path.

Filename.dirname has some special logic under Win32 to extract the "drive" component. Shouldn't something similar be done for such UNC server component, which are also "roots"?


This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Feb 6, 2019

Comment author: @dbuenzli

I guess you already know that Windows paths are hairy. Here's a good reference about them:

The path_start function here:

which I ported from the Fpath library should determine the start of a windows path using String's functions but I didn't test it thoroughly for now. It should handle these various test cases:

@vicuna vicuna added the stdlib label Mar 14, 2019

@nojb nojb added the windows label Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.