Source File
match.go
Belonging Package
path/filepath
package filepath
import (
)
var ErrBadPattern = errors.New("syntax error in pattern")
for := 0; < len() && [] != Separator; ++ {
, , := matchChunk(, [+1:])
var rune
if ! {
var int
, = utf8.DecodeRuneInString()
= [:]
}
:= false
:= 0
for {
if len() > 0 && [0] == ']' && > 0 {
= [1:]
break
}
var , rune
if , , = getEsc(); != nil {
return "", false,
}
=
if [0] == '-' {
if , , = getEsc([1:]); != nil {
return "", false,
}
}
if <= && <= {
= true
}
++
}
if == {
= true
}
case '?':
if ! {
if [0] == Separator {
= true
}
, := utf8.DecodeRuneInString()
= [:]
}
= [1:]
case '\\':
if runtime.GOOS != "windows" {
= [1:]
if len() == 0 {
return "", false, ErrBadPattern
}
}
fallthrough
default:
if ! {
if [0] != [0] {
= true
}
= [1:]
}
= [1:]
}
}
if {
return "", false, nil
}
return , true, nil
}
func ( string) ( rune, string, error) {
if len() == 0 || [0] == '-' || [0] == ']' {
= ErrBadPattern
return
}
if [0] == '\\' && runtime.GOOS != "windows" {
= [1:]
if len() == 0 {
= ErrBadPattern
return
}
}
, := utf8.DecodeRuneInString()
if == utf8.RuneError && == 1 {
= ErrBadPattern
}
= [:]
if len() == 0 {
= ErrBadPattern
}
return
}
return
default:
return [0 : len()-1] // chop off trailing separator
}
}
func ( string) ( int, string) {
:= volumeNameLen()
switch {
case == "":
return 0, "."
func (, string, []string) ( []string, error) {
=
, := os.Stat()
if != nil {
return // ignore I/O error
}
if !.IsDir() {
return // ignore I/O error
}
, := os.Open()
if != nil {
return // ignore I/O error
}
defer .Close()
, := .Readdirnames(-1)
sort.Strings()
for , := range {
, := Match(, )
if != nil {
return ,
}
if {
= append(, Join(, ))
}
}
return
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |