On Mar 28 19:18, LIU Hao wrote:
> 在 2023/3/28 10:49, LIU Hao 写道:
> > > According to Microsoft documentation about paths, which I linked
> > > yesterday, the `\\host\share` part
> > is the name of a volume, so I think only the CMD behavior is right:
> > `dirname()` should not remove `..` which would move to a different
> > volume. And here is the alternative patch.
>
> I had some discussion with Corinna Vinschen about these implementation
> details: The behavior of Cygwin about `\\host` is emulated, so it looks like
> Explorer. Our conclusion is that `\\host\` without a share name is not a
> valid UNC path.
Just for the records, Cygwin implementes virtual directories for // and
//host. You can enumerate locale SMB servers with `ls -l //', and
you can enumerate shares hosted by "host" by running `ls -l //host'.
Internally we use the WNet functions and `ls //' is just as slow and
spotty as the Explorer "Network' view...
> So far the question is all about whether `dirname()` is allowed to remove
> the shared name from a UNC path. I suspect not, mainly due to the following
> reasons:
>
> 1. `\\host` is valid for Cygwin because of the aforementioned emulation. It is
> however not a valid path for mingw-w64, and `dirname()` should not provide
> invalid paths.
> 2. As its consequence, `basename("\\host\share")` would yield `share` as if
> it was a directory. It is not.
> 3. It would be confusing that `dirname("\\host\share")` and
> `"\\host\share\.."`
> do not designate the same location. [Note in the latest patch
> `basename("\\host\share")` yields `"\"`.]
My POV is this:
Either you allow to split the *entire* share path, so you can use
dirname/basename to split \\host\share into the host and the share path,
and also to split \\ and host. That would allow to inspect the host and
share components using the same functions.
Or you value the fact that the resulting path is still valid higher,
then you have to stop dirname at \\host\share and never split these
paths.
One problem you have with the latter approach is this: What do you do
with input paths of the form "\\host"? In other words, what do you
return if the input is invalid? In theory it should stay unchanged,
so dirname should just return the invalid path verbatim.
Corinna
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public