MCPcopy
hub / github.com/spicetify/cli / GetStateFolder

Function GetStateFolder

src/utils/path-utils.go:119–148  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

117}
118
119func GetStateFolder(name string) string {
120 result, isAvailable := os.LookupEnv("SPICETIFY_STATE")
121 defer func() { CheckExistAndCreate(result) }()
122
123 if isAvailable && len(result) > 0 {
124 return result
125 }
126
127 if runtime.GOOS == "windows" {
128 parent := os.Getenv("APPDATA")
129
130 result = filepath.Join(parent, "spicetify")
131 } else if runtime.GOOS == "linux" {
132 parent, isAvailable := os.LookupEnv("XDG_STATE_HOME")
133
134 if !isAvailable || len(parent) == 0 {
135 parent = filepath.Join(os.Getenv("HOME"), ".local", "state")
136 CheckExistAndCreate(parent)
137 }
138
139 result = filepath.Join(parent, "spicetify")
140 } else if runtime.GOOS == "darwin" {
141 parent := filepath.Join(os.Getenv("HOME"), ".local", "state")
142 CheckExistAndCreate(parent)
143
144 result = filepath.Join(parent, "spicetify")
145 }
146
147 return GetSubFolder(result, name)
148}
149
150// GetSubFolder checks if folder `name` is available in specified folder,
151// else creates then returns the path.

Callers 3

cmd.goFile · 0.92
getExtractFolderFunction · 0.92
MigrateFoldersFunction · 0.85

Calls 2

CheckExistAndCreateFunction · 0.85
GetSubFolderFunction · 0.85

Tested by

no test coverage detected