github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/go/internal/str/path.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package str 6 7 // HasPathPrefix reports whether the slash-separated path s 8 // begins with the elements in prefix. 9 func HasPathPrefix(s, prefix string) bool 10 11 // HasFilePathPrefix reports whether the filesystem path s 12 // begins with the elements in prefix. 13 // 14 // HasFilePathPrefix is case-sensitive (except for volume names) even if the 15 // filesystem is not, does not apply Unicode normalization even if the 16 // filesystem does, and assumes that all path separators are canonicalized to 17 // filepath.Separator (as returned by filepath.Clean). 18 func HasFilePathPrefix(s, prefix string) bool 19 20 // TrimFilePathPrefix returns s without the leading path elements in prefix, 21 // such that joining the string to prefix produces s. 22 // 23 // If s does not start with prefix (HasFilePathPrefix with the same arguments 24 // returns false), TrimFilePathPrefix returns s. If s equals prefix, 25 // TrimFilePathPrefix returns "". 26 func TrimFilePathPrefix(s, prefix string) string 27 28 // WithFilePathSeparator returns s with a trailing path separator, or the empty 29 // string if s is empty. 30 func WithFilePathSeparator(s string) string 31 32 // QuoteGlob returns s with all Glob metacharacters quoted. 33 // We don't try to handle backslash here, as that can appear in a 34 // file path on Windows. 35 func QuoteGlob(s string) string