MCPcopy Index your code
hub / github.com/jetify-com/devbox / GlobalDataPath

Function GlobalDataPath

internal/devbox/global.go:19–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17const currentGlobalProfile = "default"
18
19func GlobalDataPath() (string, error) {
20 path := xdg.DataSubpath(filepath.Join("devbox/global", currentGlobalProfile))
21 if err := os.MkdirAll(path, 0o755); err != nil {
22 return "", errors.WithStack(err)
23 }
24
25 nixProfilePath := filepath.Join(path)
26 currentPath := xdg.DataSubpath("devbox/global/current")
27
28 // For now default is always current. In the future we will support multiple
29 // and allow user to switch. Remove any existing symlink and create a new one
30 // because previous versions of devbox may have created a symlink to a
31 // different profile.
32 existing, _ := os.Readlink(currentPath)
33 if existing != nixProfilePath {
34 _ = os.Remove(currentPath)
35 }
36
37 err := os.Symlink(nixProfilePath, currentPath)
38 if err != nil && !errors.Is(err, fs.ErrExist) {
39 return "", errors.WithStack(err)
40 }
41
42 return path, nil
43}

Callers 3

ensureGlobalConfigFunction · 0.92
OpenFunction · 0.85
isGlobalMethod · 0.85

Calls 4

DataSubpathFunction · 0.92
ReadlinkMethod · 0.80
IsMethod · 0.80
RemoveMethod · 0.45

Tested by

no test coverage detected