mirror of
https://github.com/golang/go
synced 2024-11-17 06:04:47 -07:00
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 <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>
This commit is contained in:
parent
b899e0b8cc
commit
e803857813
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user