Fix handling of single letter shares in UNC paths in wxFileName

This comes at the price of breaking compatibility and returning
"\\share" rather than just "share" from wxFileName::GetVolume() for the
UNC paths. This breakage seems justified because it is required in order
to allow application code to distinguish between paths "x:\foo" and
"\\x\foo", which was previously impossible as GetVolume() returned just
"x" in both cases.

Document this change, adjust the existing checks for the new GetVolume()
semantics and add a new test which passes now, but didn't pass before.

Closes #19255.

This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
Vadim Zeitlin
2021-09-15 01:51:35 +01:00
parent 7e4b54a00a
commit 549e0a59b1
5 changed files with 155 additions and 98 deletions

View File

@@ -859,9 +859,19 @@ public:
wxDateTime* dtCreate) const;
/**
Returns the string containing the volume for this file name, empty if it
doesn't have one or if the file system doesn't support volumes at all
(for example, Unix).
Returns the string containing the volume for this file name.
The returned string is empty if this object doesn't have a volume name,
as is always the case for the paths in Unix format which don't support
volumes at all.
Note that for @c wxPATH_DOS format paths, the returned string may have
one of the following forms:
- Just a single letter, for the usual drive letter volumes, e.g. @c C.
- A share name preceded by a double backslash, e.g. @c \\\\share.
- A GUID volume preceded by a double backslash and a question mark,
e.g. @c \\\\?\\Volume{12345678-9abc-def0-1234-56789abcdef0}.
*/
wxString GetVolume() const;