MCPcopy Index your code
hub / github.com/coder/coder / walkRoot

Function walkRoot

agent/filefinder/engine.go:60–88  ·  view source on GitHub ↗

walkRoot performs a full filesystem walk of absRoot and returns a populated Index containing all discovered files and directories.

(absRoot string)

Source from the content-addressed store, hash-verified

58// walkRoot performs a full filesystem walk of absRoot and returns
59// a populated Index containing all discovered files and directories.
60func walkRoot(absRoot string) (*Index, error) {
61 idx := NewIndex()
62 err := filepath.Walk(absRoot, func(path string, info os.FileInfo, walkErr error) error {
63 if walkErr != nil {
64 return nil //nolint:nilerr
65 }
66 base := filepath.Base(path)
67 if _, skip := skipDirs[base]; skip && info.IsDir() {
68 return filepath.SkipDir
69 }
70 if path == absRoot {
71 return nil
72 }
73 relPath, relErr := filepath.Rel(absRoot, path)
74 if relErr != nil {
75 return nil //nolint:nilerr
76 }
77 relPath = filepath.ToSlash(relPath)
78 var flags uint16
79 if info.IsDir() {
80 flags = uint16(FlagDir)
81 } else if info.Mode()&os.ModeSymlink != 0 {
82 flags = uint16(FlagSymlink)
83 }
84 idx.Add(relPath, flags)
85 return nil
86 })
87 return idx, err
88}
89
90// NewEngine creates a new Engine.
91func NewEngine(logger slog.Logger) *Engine {

Callers 3

AddRootMethod · 0.85
RebuildMethod · 0.85
BuildTestIndexFunction · 0.85

Calls 2

AddMethod · 0.95
NewIndexFunction · 0.85

Tested by 1

BuildTestIndexFunction · 0.68