]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: delete the deprecated joinNonEmpty and isUNC
authorAndy Pan <panjf2000@gmail.com>
Fri, 16 Feb 2024 05:53:05 +0000 (13:53 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 23 Feb 2024 23:50:06 +0000 (23:50 +0000)
Change-Id: I4ce88b2e8e8d24afb63ca7246ce0c418fcb02c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/564715
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/path/filepath/path_windows.go

index eacab0e5ced678adb364c974bf192ffb29e3e0e7..6adb7d4bc4b2f007dacbb3782b7717eff825eb2e 100644 (file)
@@ -277,46 +277,6 @@ func join(elem []string) string {
        return Clean(b.String())
 }
 
-// joinNonEmpty is like join, but it assumes that the first element is non-empty.
-func joinNonEmpty(elem []string) string {
-       if len(elem[0]) == 2 && elem[0][1] == ':' {
-               // First element is drive letter without terminating slash.
-               // Keep path relative to current directory on that drive.
-               // Skip empty elements.
-               i := 1
-               for ; i < len(elem); i++ {
-                       if elem[i] != "" {
-                               break
-                       }
-               }
-               return Clean(elem[0] + strings.Join(elem[i:], string(Separator)))
-       }
-       // The following logic prevents Join from inadvertently creating a
-       // UNC path on Windows. Unless the first element is a UNC path, Join
-       // shouldn't create a UNC path. See golang.org/issue/9167.
-       p := Clean(strings.Join(elem, string(Separator)))
-       if !isUNC(p) {
-               return p
-       }
-       // p == UNC only allowed when the first element is a UNC path.
-       head := Clean(elem[0])
-       if isUNC(head) {
-               return p
-       }
-       // head + tail == UNC, but joining two non-UNC paths should not result
-       // in a UNC path. Undo creation of UNC path.
-       tail := Clean(strings.Join(elem[1:], string(Separator)))
-       if head[len(head)-1] == Separator {
-               return head + tail
-       }
-       return head + string(Separator) + tail
-}
-
-// isUNC reports whether path is a UNC path.
-func isUNC(path string) bool {
-       return len(path) > 1 && isSlash(path[0]) && isSlash(path[1])
-}
-
 func sameWord(a, b string) bool {
        return strings.EqualFold(a, b)
 }