I want to make a library that (among other things) parses UNC paths, but I don't fully understand the grammar.
Common example is: \\server\share\path
Are all of those required for a valid file path? I can navigate to \\server
(without share
) using Windows Explorer, but I assume it is using some share discovery protocol, not something filesystem APIs understand — is this right?
You are correct. A UNC path is required to have share name component.
Quoting MSDN:
UNC = \\<hostname>\<sharename>[\<objectname>]*
The
<hostname>
,<sharename>
, and<objectname>
are referred to as "pathname components" or "path components". A valid UNC path consists of two or more path components.