From e80385781397dc68894d4e8f2ae6741059eb9d9c Mon Sep 17 00:00:00 2001 From: Andy Pan Date: Fri, 16 Feb 2024 13:53:05 +0800 Subject: [PATCH] path/filepath: delete the deprecated joinNonEmpty and isUNC Change-Id: I4ce88b2e8e8d24afb63ca7246ce0c418fcb02c9e Reviewed-on: https://go-review.googlesource.com/c/go/+/564715 Reviewed-by: Damien Neil Reviewed-by: Ian Lance Taylor Auto-Submit: Damien Neil LUCI-TryBot-Result: Go LUCI --- src/path/filepath/path_windows.go | 40 ------------------------------- 1 file changed, 40 deletions(-) diff --git a/src/path/filepath/path_windows.go b/src/path/filepath/path_windows.go index eacab0e5ced..6adb7d4bc4b 100644 --- a/src/path/filepath/path_windows.go +++ b/src/path/filepath/path_windows.go @@ -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) }