gitlab.com/evatix-go/core@v1.3.55/chmodhelper/GetRecursivePathsContinueOnError.go (about) 1 package chmodhelper 2 3 import ( 4 "io/fs" 5 "path/filepath" 6 7 "gitlab.com/evatix-go/core/constants" 8 "gitlab.com/evatix-go/core/errcore" 9 ) 10 11 func GetRecursivePathsContinueOnError( 12 rootPath string, 13 ) ([]string, error) { 14 stat := GetPathExistStat(rootPath) 15 16 if !stat.IsExist { 17 return []string{}, errcore.PathsMissingOrHavingIssuesType. 18 ErrorRefOnly(rootPath) 19 } 20 21 if stat.IsFile() { 22 return []string{rootPath}, nil 23 } 24 25 allPaths := make( 26 []string, 27 0, 28 constants.Capacity128) 29 var sliceErr []string 30 31 finalErr := filepath.Walk( 32 rootPath, 33 func(path string, info fs.FileInfo, err error) error { 34 if err != nil { 35 sliceErr = append( 36 sliceErr, 37 err.Error()+constants.HyphenAngelRight+path) 38 39 return nil 40 } 41 42 allPaths = append(allPaths, path) 43 44 return nil 45 }) 46 47 if finalErr != nil { 48 sliceErr = append( 49 sliceErr, 50 finalErr.Error()+constants.HyphenAngelRight+rootPath) 51 } 52 53 return allPaths, errcore.SliceToError(sliceErr) 54 }