(name string)
| 117 | } |
| 118 | |
| 119 | func 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. |
no test coverage detected