MCPcopy
hub / github.com/perkeep/perkeep / hasComponent

Function hasComponent

pkg/client/config.go:576–595  ·  view source on GitHub ↗

hasComponent returns whether the pathComponent is a path component of fullpath. i.e it is a part of fullpath that fits exactly between two path separators.

(component, fullpath string)

Source from the content-addressed store, hash-verified

574// fullpath. i.e it is a part of fullpath that fits exactly between two path
575// separators.
576func hasComponent(component, fullpath string) bool {
577 // trim Windows volume name
578 fullpath = strings.TrimPrefix(fullpath, filepath.VolumeName(fullpath))
579 for {
580 i := strings.Index(fullpath, component)
581 if i == -1 {
582 return false
583 }
584 if i != 0 && fullpath[i-1] == filepath.Separator {
585 componentEnd := i + len(component)
586 if componentEnd == len(fullpath) {
587 return true
588 }
589 if fullpath[componentEnd] == filepath.Separator {
590 return true
591 }
592 }
593 fullpath = fullpath[i+1:]
594 }
595}

Callers 1

newIgnoreCheckerFunction · 0.85

Calls 1

IndexMethod · 0.80

Tested by

no test coverage detected