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