On Mar 29 09:14, LIU Hao wrote:
> 在 2023/3/29 01:53, Corinna Vinschen 写道:
> > Backslahs is one of the characters not allowed as part of a share
> > name, just as it is not allowed as part of a filename.  I. e.
> > 
> >    \\host\share is ok
> >    \\host\\share can't exist
> 
> Yes, so the backslash between the host name and share name is special,
> right? By convention `dirname()` removes consecutive slashes, but it should
> not remove this special one?

Uhm, no.  You wrote

> > No, this would allow splitting `\\host\\share` as `host` and `share`. In
> > this path the share name is `\share`, and does not match `share`.

I was just pointing out that "\foo" can't be a share name, because
backslashes can't be part of a name.

On second thought, maybe I don't understand what you were trying to say.
Can you rephrase, please?

> > Hmm, ok.  But \\host\ is just as invalid as \\host...
> 
> Because these two functions can't report errors, maybe an invalid output
> from an invalid input is acceptable, but a valid output from an invalid
> input (e.g. `\\host\share` from `\\host\\share`) or an invalid output from a
> valid input (e.g. `\\host` from `\\host\share`) is not acceptable?

Actually, the dirname function is not supposed to fold slashes (or
backslashes) at all, except at the start of the path.  It's also not
supposed to throw any errors.  It just cuts the path so that the last
path component is dropped.

  dirname("/////a///b///c///") --> /////a///b
  dirname("/////a///b") --> /////a
  dirname("/////a") --> /

In terms of the double (back)slashes, they are only special at the start
of the path.  Per POSIX:

 "A pathname that begins with two successive slashes may be interpreted
  in an implementation-defined manner, although more than two leading
  slashes shall be treated as a single slash."

I.e.:

  dirname("///a") --> /
  dirname("//a") --> //
  dirname("/a") --> /


Corinna


_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to