MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / PathFor

Method PathFor

internal/editorconfig/json_tool.go:40–56  ·  view source on GitHub ↗

PathFor returns the on-disk path used for read/write at the given scope. The first user path is used for write, even when no file exists yet (the caller's responsibility is to create the directory).

(scope Scope)

Source from the content-addressed store, hash-verified

38// The first user path is used for write, even when no file exists yet (the
39// caller's responsibility is to create the directory).
40func (c *jsonToolConfig) PathFor(scope Scope) string {
41 switch scope {
42 case UserScope:
43 paths := c.UserPaths()
44 for _, p := range paths {
45 if pathutil.Exists(p) {
46 return p
47 }
48 }
49 if len(paths) > 0 {
50 return paths[0]
51 }
52 case ProjectScope:
53 return c.ProjectPath()
54 }
55 return ""
56}
57
58func (c *jsonToolConfig) Load(scope Scope) (map[string]any, string, error) {
59 path := c.PathFor(scope)

Callers 4

LoadMethod · 0.95
LoadAllMethod · 0.95
SetMethod · 0.95
UnsetMethod · 0.95

Calls 3

UserPathsMethod · 0.95
ProjectPathMethod · 0.95
ExistsFunction · 0.92

Tested by

no test coverage detected