diff options
Diffstat (limited to 'src/path/filepath/path_windows.go')
-rw-r--r-- | src/path/filepath/path_windows.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go index c490424f20..eacab0e5ce 100644 --- a/src/path/filepath/path_windows.go +++ b/src/path/filepath/path_windows.go @@ -102,12 +102,14 @@ func volumeNameLen(path string) int { // \\.\unc\a\b\..\c into \\.\unc\a\c. return uncLen(path, len(`\\.\UNC\`)) - case pathHasPrefixFold(path, `\\.`): - // Path starts with \\., and is a Local Device path. + case pathHasPrefixFold(path, `\\.`) || + pathHasPrefixFold(path, `\\?`) || pathHasPrefixFold(path, `\??`): + // Path starts with \\.\, and is a Local Device path; or + // path starts with \\?\ or \??\ and is a Root Local Device path. // - // We currently treat the next component after the \\.\ prefix - // as part of the volume name, although there doesn't seem to be - // a principled reason to do this. + // We treat the next component after the \\.\ prefix as + // part of the volume name, which means Clean(`\\?\c:\`) + // won't remove the trailing \. (See #64028.) if len(path) == 3 { return 3 // exactly \\. } @@ -117,14 +119,6 @@ func volumeNameLen(path string) int { } return len(path) - len(rest) - 1 - case pathHasPrefixFold(path, `\\?`) || pathHasPrefixFold(path, `\??`): - // Path starts with \\?\ or \??\, and is a Root Local Device path. - // - // While Windows usually treats / and \ as equivalent, - // /??/ does not seem to be recognized as a Root Local Device path. - // We treat it as one anyway here to be safe. - return 3 - case len(path) >= 2 && isSlash(path[1]): // Path starts with \\, and is a UNC path. return uncLen(path, 2) |