MCPcopy Create free account
hub / github.com/github/gh-aw / findFileInDir

Function findFileInDir

pkg/cli/copilot_events_jsonl.go:141–160  ·  view source on GitHub ↗

findFileInDir searches for a file by name within dir (recursively). Returns the first matching path, or empty string if not found.

(dir, name string)

Source from the content-addressed store, hash-verified

139// findFileInDir searches for a file by name within dir (recursively).
140// Returns the first matching path, or empty string if not found.
141func findFileInDir(dir, name string) string {
142 var found string
143 if walkErr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
144 if err != nil {
145 copilotEventsJSONLLog.Printf("walk error at %s: %v", path, err)
146 return nil
147 }
148 if info == nil {
149 return nil
150 }
151 if !info.IsDir() && info.Name() == name && found == "" {
152 found = path
153 return errWalkStop
154 }
155 return nil
156 }); walkErr != nil && !errors.Is(walkErr, errWalkStop) {
157 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("filesystem error walking %s: %v", dir, walkErr)))
158 }
159 return found
160}
161
162// parseEventsJSONLMetrics parses a Copilot events.jsonl file and extracts log metrics.
163//

Callers 1

findEventsJSONLFileFunction · 0.85

Calls 2

FormatWarningMessageFunction · 0.92
PrintfMethod · 0.45

Tested by

no test coverage detected