...

Source file src/github.com/monochromegane/go-gitignore/full_scan_patterns.go

Documentation: github.com/monochromegane/go-gitignore

     1  package gitignore
     2  
     3  import "strings"
     4  
     5  // Only benchmark use
     6  type fullScanPatterns struct {
     7  	absolute patterns
     8  	relative patterns
     9  }
    10  
    11  func newFullScanPatterns() *fullScanPatterns {
    12  	return &fullScanPatterns{
    13  		absolute: patterns{},
    14  		relative: patterns{},
    15  	}
    16  }
    17  
    18  func (ps *fullScanPatterns) add(pattern string) {
    19  	if strings.HasPrefix(pattern, "/") {
    20  		ps.absolute.add(newPattern(pattern))
    21  	} else {
    22  		ps.relative.add(newPattern(pattern))
    23  	}
    24  }
    25  
    26  func (ps fullScanPatterns) match(path string, isDir bool) bool {
    27  	if ps.absolute.match(path, isDir) {
    28  		return true
    29  	}
    30  	return ps.relative.match(path, isDir)
    31  }
    32  

View as plain text