MCPcopy
hub / github.com/docker/compose / greatestExistingAncestor

Function greatestExistingAncestor

pkg/watch/paths.go:25–41  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

23)
24
25func greatestExistingAncestor(path string) (string, error) {
26 if path == string(filepath.Separator) ||
27 path == fmt.Sprintf("%s%s", filepath.VolumeName(path), string(filepath.Separator)) {
28 return "", fmt.Errorf("cannot watch root directory")
29 }
30
31 _, err := os.Stat(path)
32 if err != nil && !os.IsNotExist(err) {
33 return "", fmt.Errorf("os.Stat(%q): %w", path, err)
34 }
35
36 if os.IsNotExist(err) {
37 return greatestExistingAncestor(filepath.Dir(path))
38 }
39
40 return path, nil
41}

Callers 2

Calls 1

DirMethod · 0.45

Tested by 1