(leafDir, targetFile string, dir bool)
| 88 | } |
| 89 | |
| 90 | func findPath(leafDir, targetFile string, dir bool) (string, bool) { |
| 91 | if len(leafDir) == 0 { |
| 92 | return "", false |
| 93 | } |
| 94 | spread := filepath.Join(leafDir, targetFile) |
| 95 | if exists, err := pathExists(spread, dir); err == nil && exists { |
| 96 | return spread, true |
| 97 | } else { |
| 98 | if leafDir == "/" { |
| 99 | return "", false |
| 100 | } |
| 101 | parent := filepath.Dir(leafDir) |
| 102 | return findPath(parent, targetFile, dir) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | func pathExists(path string, dir bool) (bool, error) { |
| 107 | info, err := os.Stat(path) |