MCPcopy Create free account
hub / github.com/bufbuild/buf / GetFileInfos

Function GetFileInfos

private/bufpkg/bufmodule/module_read_bucket.go:138–156  ·  view source on GitHub ↗

GetFileInfos is a convenience function that walks the ModuleReadBucket and gets all the FileInfos. Sorted by path.

(ctx context.Context, moduleReadBucket ModuleReadBucket)

Source from the content-addressed store, hash-verified

136//
137// Sorted by path.
138func GetFileInfos(ctx context.Context, moduleReadBucket ModuleReadBucket) ([]FileInfo, error) {
139 var fileInfos []FileInfo
140 if err := moduleReadBucket.WalkFileInfos(
141 ctx,
142 func(fileInfo FileInfo) error {
143 fileInfos = append(fileInfos, fileInfo)
144 return nil
145 },
146 ); err != nil {
147 return nil, err
148 }
149 sort.Slice(
150 fileInfos,
151 func(i int, j int) bool {
152 return fileInfos[i].Path() < fileInfos[j].Path()
153 },
154 )
155 return fileInfos, nil
156}
157
158// GetTargetFileInfos is a convenience function that walks the ModuleReadBucket and gets
159// all the FileInfos where IsTargetFile() is set to true.

Callers 5

testFilePathsFunction · 0.92
printModuleFunction · 0.92
GetFilePathsFunction · 0.85

Calls 2

WalkFileInfosMethod · 0.65
PathMethod · 0.65

Tested by 1

testFilePathsFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…