our own readdir, which skips the files it cannot lstat
(name string)
| 15 | |
| 16 | // our own readdir, which skips the files it cannot lstat |
| 17 | func readdir_lstat(name string) ([]os.FileInfo, error) { |
| 18 | f, err := os.Open(name) |
| 19 | if err != nil { |
| 20 | return nil, err |
| 21 | } |
| 22 | defer f.Close() |
| 23 | |
| 24 | names, err := f.Readdirnames(-1) |
| 25 | if err != nil { |
| 26 | return nil, err |
| 27 | } |
| 28 | |
| 29 | out := make([]os.FileInfo, 0, len(names)) |
| 30 | for _, lname := range names { |
| 31 | s, err := os.Lstat(filepath.Join(name, lname)) |
| 32 | if err != nil { |
| 33 | continue |
| 34 | } |
| 35 | out = append(out, s) |
| 36 | } |
| 37 | return out, nil |
| 38 | } |
| 39 | |
| 40 | // our other readdir function, only opens and reads |
| 41 | func readdir(dirname string) []os.FileInfo { |
no outgoing calls
no test coverage detected