MCPcopy Create free account
hub / github.com/NVIDIA/gpu-operator / findFile

Method findFile

cmd/nvidia-validator/find.go:86–98  ·  view source on GitHub ↗

findFile searches the root for a specified file. A number of folders can be specified to search in addition to the root itself. If the file represents a symlink, this is resolved and the final path is returned.

(name string, searchIn ...string)

Source from the content-addressed store, hash-verified

84// A number of folders can be specified to search in addition to the root itself.
85// If the file represents a symlink, this is resolved and the final path is returned.
86func (r root) findFile(name string, searchIn ...string) (string, error) {
87
88 for _, d := range append([]string{"/"}, searchIn...) {
89 l := filepath.Join(string(r), d, name)
90 candidate, err := resolveLink(l)
91 if err != nil {
92 continue
93 }
94 return candidate, nil
95 }
96
97 return "", fmt.Errorf("error locating %q", name)
98}
99
100// resolveLink finds the target of a symlink or the file itself in the
101// case of a regular file.

Callers 2

getDriverLibraryPathMethod · 0.95
getNvidiaSMIPathMethod · 0.95

Calls 1

resolveLinkFunction · 0.85

Tested by

no test coverage detected