1 // Package fsutil defiens a set of internal utility functions used to 2 // interact with the file system. 3 package fsutil 4 5 import ( 6 "fmt" 7 "os" 8 "path/filepath" 9 ) 10 11 // IsMetaFile tests wheter a DirEntry appears to be a metadata file or not. 12 func IsMetaFile(e os.DirEntry) (bool, error) { 13 if e.IsDir() || filepath.Ext(e.Name()) != ".json" { 14 return false, nil 15 } 16 17 info, err := e.Info() 18 if err != nil { 19 return false, fmt.Errorf("error retrieving FileInfo for %s: %w", e.Name(), err) 20 } 21 22 return info.Mode().IsRegular(), nil 23 } 24