MCPcopy
hub / github.com/kashav/fsql / walkFunc

Method walkFunc

query/query.go:85–119  ·  view source on GitHub ↗

walkFunc returns a filepath.WalkFunc which evaluates the condition tree against the given file.

(seen map[string]bool, excluder Excluder,
	workFunc interface{})

Source from the content-addressed store, hash-verified

83// walkFunc returns a filepath.WalkFunc which evaluates the condition tree
84// against the given file.
85func (q *Query) walkFunc(seen map[string]bool, excluder Excluder,
86 workFunc interface{}) filepath.WalkFunc {
87 return func(path string, info os.FileInfo, err error) error {
88 if err != nil {
89 return err
90 }
91
92 if path == "." {
93 return nil
94 }
95
96 // Avoid walking a single directory more than once.
97 if _, ok := seen[path]; ok {
98 return nil
99 }
100 seen[path] = true
101
102 if excluder.shouldExclude(path) {
103 return nil
104 }
105
106 if ok, err := q.ConditionTree.evaluateTree(path, info); err != nil {
107 return err
108 } else if !ok {
109 return nil
110 }
111
112 results, err := q.applyModifiers(path, info)
113 if err != nil {
114 return err
115 }
116 workFunc.(func(string, os.FileInfo, map[string]interface{}))(path, info, results)
117 return nil
118 }
119}

Callers 1

ExecuteMethod · 0.95

Calls 3

applyModifiersMethod · 0.95
evaluateTreeMethod · 0.80
shouldExcludeMethod · 0.65

Tested by

no test coverage detected