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

Open
vicuna opened this Issue Feb 6, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

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"?

@vicuna

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:

https://docs.racket-lang.org/reference/windowspaths.html

The path_start function here:

https://github.com/b0-system/b0/blob/df3115abe3269f799973c253b41340243df774c1/src-std/b0_std.ml#L2008-L2038

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:

https://github.com/dbuenzli/fpath/blob/f679f231ee994e30ca2f5f2b327b3750e9bdf82d/test/test_fpath.ml#L145-L160

@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.