MCPcopy Create free account
hub / github.com/brimdata/super / getDefaultDataDir

Function getDefaultDataDir

cli/dbflags/datadir.go:11–30  ·  view source on GitHub ↗

getDefaultDataDir returns the default data directory for the current user. Derived from https://github.com/btcsuite/btcd/blob/master/btcutil/appdata.go

()

Source from the content-addressed store, hash-verified

9// getDefaultDataDir returns the default data directory for the current user.
10// Derived from https://github.com/btcsuite/btcd/blob/master/btcutil/appdata.go
11func getDefaultDataDir() string {
12 // Resolve the XDG data home directory if set.
13 if xdgDataHome := os.Getenv("XDG_DATA_HOME"); xdgDataHome != "" {
14 return filepath.Join(xdgDataHome, "super")
15 }
16 if runtime.GOOS == "windows" {
17 if appData := os.Getenv("LOCALAPPDATA"); appData != "" {
18 return filepath.Join(appData, "super")
19 }
20 }
21 if homeDir, _ := os.UserHomeDir(); homeDir != "" {
22 // Follow the XDG spec which states:
23 // If $XDG_DATA_HOME is either not set or empty, a default equal to
24 // $HOME/.local/share should be used.
25 return filepath.Join(homeDir, ".local", "share", "super")
26 }
27 // Return an empty string which will cause an error if a default data
28 // directory cannot be found.
29 return ""
30}

Callers 1

URIMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected