ContainsPath checks whether child is contained within or equal to p. Since Path values are already rooted, reduced, and case-canonicalized, this is a simple string prefix check.
(child Path)
| 1036 | // Since Path values are already rooted, reduced, and case-canonicalized, |
| 1037 | // this is a simple string prefix check. |
| 1038 | func (p Path) ContainsPath(child Path) bool { |
| 1039 | if len(p) == 0 { |
| 1040 | return false |
| 1041 | } |
| 1042 | return p == child || len(child) > len(p) && strings.HasPrefix(string(child), string(p)) && (p[len(p)-1] == '/' || child[len(p)] == '/') |
| 1043 | } |
| 1044 | |
| 1045 | func FileExtensionIs(path string, extension string) bool { |
| 1046 | return len(path) > len(extension) && strings.HasSuffix(path, extension) |
no test coverage detected