MCPcopy Create free account
hub / github.com/coder/coder / resolvePath

Function resolvePath

agent/x/agentmcp/configwatcher.go:403–418  ·  view source on GitHub ↗

resolvePath converts a path to an absolute, symlink-resolved form. If the file does not exist, falls back to filepath.Abs so the caller can still arm an ancestor directory.

(p string)

Source from the content-addressed store, hash-verified

401// form. If the file does not exist, falls back to filepath.Abs so
402// the caller can still arm an ancestor directory.
403func resolvePath(p string) string {
404 if p == "" {
405 return ""
406 }
407 if abs, err := filepath.Abs(p); err == nil {
408 // EvalSymlinks fails on non-existent paths. Resolve as
409 // far as possible without erroring out: walk up until
410 // we find an existing ancestor, eval its symlinks, and
411 // re-join the trailing segments.
412 if resolved, err := filepath.EvalSymlinks(abs); err == nil {
413 return resolved
414 }
415 return resolvePathBestEffort(abs)
416 }
417 return ""
418}
419
420func resolvePathBestEffort(abs string) string {
421 dir := filepath.Dir(abs)

Callers 1

SyncMethod · 0.85

Calls 1

resolvePathBestEffortFunction · 0.85

Tested by

no test coverage detected