Debian Codegraph @

internal/sender/exclude.go

raw symbols SCIP
1 package senderscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/
2
3 import (
4 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
5 "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/"
6 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
7
8 "github.com/gokrazy/rsync/internal/rsyncwirescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/rsyncwire`/"
9 )
10
11 type filterRuleListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList# struct {
12 Filtersscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#Filters. []*filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#
13 }
14
15 // exclude.c:add_rule
16 func (l *filterRuleListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#) addRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#addRule().(fr *filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#) {
17 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasSuffixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasSuffix().(fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern., "/") {
18 fr.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. |= filtruleDirectoryscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleDirectory.
19 fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern. = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimSuffix().(fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern., "/")
20 }
21 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ContainsFuncscip-go gomod github.com/golang/go/src go1.25.0 strings/ContainsFunc().(fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern., func(r rune) bool {
22 return r == '*' || r == '[' || r == '?'
23 }) {
24 fr.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. |= filtruleWildscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleWild.
25 }
26 l.Filtersscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#Filters. = append(l.Filtersscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#Filters., fr)
27 }
28
29 // exclude.c:check_filter
30 func (l *filterRuleListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#) matchesscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#matches().(name string) bool {
31 for _, fr := range l.Filtersscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#Filters. {
32 if fr.matchesscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#matches().(name) {
33 return true
34 }
35 }
36 return false
37 }
38
39 // exclude.c:recv_filter_list
40 func RecvFilterListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/RecvFilterList().(c *rsyncwirescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/rsyncwire`/.Connscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/rsyncwire`/Conn#) (*filterRuleListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#, error) {
41 var l filterRuleListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#
42 const exclusionListEnd = 0
43 for {
44 length, err := c.ReadInt32scip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/rsyncwire`/Conn#ReadInt32().()
45 if err != nil {
46 return nil, err
47 }
48 if length == exclusionListEnd {
49 break
50 }
51 line := make([]byte, length)
52 if _, err := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadFullscip-go gomod github.com/golang/go/src go1.25.0 io/ReadFull().(c.Readerscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/rsyncwire`/Conn#Reader., line); err != nil {
53 return nil, err
54 }
55 fr, err := parseFilterscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/parseFilter().(string(line))
56 if err != nil {
57 return nil, err
58 }
59 l.addRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRuleList#addRule().(fr)
60 }
61 return &l, nil
62 }
63
64 const (
65 filtruleIncludescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleInclude. = 1 << iota
66 filtruleClearListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleClearList.
67 filtruleDirectoryscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleDirectory.
68 filtruleWildscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleWild.
69 )
70
71 type filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule# struct {
72 flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. int
73 patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern. string
74 }
75
76 // exclude.c:rule_matches
77 func (fr *filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#) matchesscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#matches().(name string) bool {
78 if fr.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag.&filtruleWildscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleWild. != 0 {
79 panic("wildcard filter rules not yet implemented")
80 }
81 if !stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.ContainsRunescip-go gomod github.com/golang/go/src go1.25.0 strings/ContainsRune().(fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern., '/') &&
82 fr.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag.&filtruleWildscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleWild. == 0 {
83 name = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(name)
84 }
85 return fr.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern. == name
86 }
87
88 // exclude.c:parse_filter_str / exclude.c:parse_rule_tok
89 func parseFilterscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/parseFilter().(line string) (*filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#, error) {
90 rule := new(filterRulescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#)
91
92 // We only support what rsync calls XFLG_OLD_PREFIXES
93 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(line, "- ") {
94 // clear include flag
95 rule.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. &= ^filtruleIncludescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleInclude.
96 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimPrefix().(line, "- ")
97 } else if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(line, "+ ") {
98 // set include flag
99 rule.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. |= filtruleIncludescip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleInclude.
100 line = stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.TrimPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/TrimPrefix().(line, "+ ")
101 } else if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(line, "!") {
102 // set clear_list flag
103 rule.flagscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#flag. |= filtruleClearListscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filtruleClearList.
104 }
105
106 rule.patternscip-go gomod github.com/gokrazy/rsync . `github.com/gokrazy/rsync/internal/sender`/filterRule#pattern. = line
107
108 return rule, nil
109 }