...

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

Documentation: github.com/monochromegane/go-gitignore

     1  package gitignore
     2  
     3  import (
     4  	"os"
     5  	"strings"
     6  )
     7  
     8  func cutN(path string, n int) (string, bool) {
     9  	isLast := true
    10  
    11  	var i, count int
    12  	for i < len(path)-1 {
    13  		if os.IsPathSeparator(path[i]) {
    14  			count++
    15  			if count >= n {
    16  				isLast = false
    17  				break
    18  			}
    19  		}
    20  		i++
    21  	}
    22  	return path[:i+1], isLast
    23  }
    24  
    25  func cutLastN(path string, n int) (string, bool) {
    26  	isLast := true
    27  	i := len(path) - 1
    28  
    29  	var count int
    30  	for i >= 0 {
    31  		if os.IsPathSeparator(path[i]) {
    32  			count++
    33  			if count >= n {
    34  				isLast = false
    35  				break
    36  			}
    37  		}
    38  		i--
    39  	}
    40  	return path[i+1:], isLast
    41  }
    42  
    43  func hasMeta(path string) bool {
    44  	return strings.IndexAny(path, "*?[") >= 0
    45  }
    46  

View as plain text