MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / findUserFolders

Function findUserFolders

src/Engine/CrossPlatform.cpp:204–269  ·  view source on GitHub ↗

* Builds a list of predefined paths for the User folder * according to the running system. * @return List of data paths. */

Source from the content-addressed store, hash-verified

202 * @return List of data paths.
203 */
204std::vector<std::string> findUserFolders()
205{
206 std::vector<std::string> list;
207
208#ifdef __MORPHOS__
209 list.push_back("PROGDIR:");
210 return list;
211#endif
212
213
214#ifdef _WIN32
215 char path[MAX_PATH];
216
217 // Get Documents folder
218 if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path)))
219 {
220 PathAppendA(path, "OpenXcom\\");
221 list.push_back(path);
222 }
223
224 // Get binary directory
225 if (GetModuleFileNameA(NULL, path, MAX_PATH) != 0)
226 {
227 PathRemoveFileSpecA(path);
228 PathAppendA(path, "user\\");
229 list.push_back(path);
230 }
231
232 // Get working directory
233 if (GetCurrentDirectoryA(MAX_PATH, path) != 0)
234 {
235 PathAppendA(path, "user\\");
236 list.push_back(path);
237 }
238#else
239#ifdef __HAIKU__
240 list.push_back("/boot/apps/OpenXcom/");
241#endif
242 char const *home = getHome();
243 char path[MAXPATHLEN];
244
245 // Get user folders
246 if (char const *const xdg_data_home = getenv("XDG_DATA_HOME"))
247 {
248 snprintf(path, MAXPATHLEN, "%s/openxcom/", xdg_data_home);
249 }
250 else
251 {
252#ifdef __APPLE__
253 snprintf(path, MAXPATHLEN, "%s/Library/Application Support/OpenXcom/", home);
254#else
255 snprintf(path, MAXPATHLEN, "%s/.local/share/openxcom/", home);
256#endif
257 }
258 list.push_back(path);
259
260 // Get old-style folder
261 snprintf(path, MAXPATHLEN, "%s/.openxcom/", home);

Callers 1

setFoldersFunction · 0.85

Calls 1

getHomeFunction · 0.85

Tested by

no test coverage detected