MCPcopy
hub / github.com/runfinch/finch / FinchRootDir

Method FinchRootDir

pkg/path/finch_windows.go:18–30  ·  view source on GitHub ↗

FinchRootDir returns the path to the Finch root directory, which is %LOCALAPPDATA% on Windows. It also canonicalizes any environment variables that may be unexpanded in the path so that all paths based on it can be passed safely to other programs which may execute outside of the user's context.

(ffd FinchFinderDeps)

Source from the content-addressed store, hash-verified

16// It also canonicalizes any environment variables that may be unexpanded in the path so that all
17// paths based on it can be passed safely to other programs which may execute outside of the user's context.
18func (Finch) FinchRootDir(ffd FinchFinderDeps) (string, error) {
19 appDir := ffd.Env("LOCALAPPDATA")
20 expandedPath, err := registry.ExpandString(appDir)
21 if err != nil {
22 return "", err
23 }
24 // reject any paths that contain unexpected characters
25 if strings.Contains(expandedPath, "&") || strings.Contains(expandedPath, `"`) {
26 return "", fmt.Errorf("unexpected LOCALAPPDATA path %q", expandedPath)
27 }
28
29 return expandedPath, nil
30}

Callers

nothing calls this directly

Calls 2

EnvMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected