github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/file/cataloger/internal/all_regular_files.go (about) 1 package internal 2 3 import ( 4 "context" 5 6 stereoscopeFile "github.com/anchore/stereoscope/pkg/file" 7 "github.com/anchore/syft/internal/log" 8 "github.com/anchore/syft/syft/file" 9 ) 10 11 func AllRegularFiles(ctx context.Context, resolver file.Resolver) (locations []file.Location) { 12 ctx, cancel := context.WithCancel(ctx) 13 defer cancel() 14 for location := range resolver.AllLocations(ctx) { 15 resolvedLocations, err := resolver.FilesByPath(location.RealPath) 16 if err != nil { 17 log.Warnf("unable to resolve %+v: %+v", location, err) 18 continue 19 } 20 21 for _, resolvedLocation := range resolvedLocations { 22 metadata, err := resolver.FileMetadataByLocation(resolvedLocation) 23 if err != nil { 24 log.Warnf("unable to get metadata for %+v: %+v", location, err) 25 continue 26 } 27 28 if metadata.Type != stereoscopeFile.TypeRegular { 29 continue 30 } 31 locations = append(locations, resolvedLocation) 32 } 33 } 34 return locations 35 }