HostDirFromRoot returns a function which finds a host directory based at the given root.
(root string)
| 291 | // HostDirFromRoot returns a function which finds a host directory |
| 292 | // based at the given root. |
| 293 | func HostDirFromRoot(root string) func(string) (string, error) { |
| 294 | return func(host string) (string, error) { |
| 295 | for _, p := range hostPaths(root, host) { |
| 296 | if _, err := os.Stat(p); err == nil { |
| 297 | return p, nil |
| 298 | } else if !os.IsNotExist(err) { |
| 299 | return "", err |
| 300 | } |
| 301 | } |
| 302 | return "", errdefs.ErrNotFound |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | // hostDirectory converts ":port" to "_port_" in directory names |
| 307 | func hostDirectory(host string) string { |
searching dependent graphs…