SearchPathRecursively walks up the directory tree starting at the given path, calling the Search function in each directory until it finds a matching file or reaches the root directory. On supported operating systems, it will also check if the user ID of the directory changes and abort if it does.
(path string, possibleFilenames []string)
| 152 | // file or reaches the root directory. On supported operating systems, it will |
| 153 | // also check if the user ID of the directory changes and abort if it does. |
| 154 | func SearchPathRecursively(path string, possibleFilenames []string) (string, error) { |
| 155 | paths, err := SearchNPathRecursively(path, possibleFilenames, 1) |
| 156 | if len(paths) > 0 { |
| 157 | // Regardless of the error, return the first possible filename. |
| 158 | return paths[0], nil |
| 159 | } else { |
| 160 | if err != nil { |
| 161 | return "", err |
| 162 | } else { |
| 163 | return "", os.ErrNotExist |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | // SearchNPathRecursively walks up the directory tree starting at the given |
| 169 | // path, calling the Search function in each directory and adding each matching |
no test coverage detected
searching dependent graphs…