* Builds a list of predefined paths for the Data folder * according to the running system. * @return List of data paths. */
| 110 | * @return List of data paths. |
| 111 | */ |
| 112 | std::vector<std::string> findDataFolders() |
| 113 | { |
| 114 | std::vector<std::string> list; |
| 115 | #ifdef __MORPHOS__ |
| 116 | list.push_back("PROGDIR:data/"); |
| 117 | return list; |
| 118 | #endif |
| 119 | |
| 120 | #ifdef _WIN32 |
| 121 | char path[MAX_PATH]; |
| 122 | |
| 123 | // Get Documents folder |
| 124 | if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path))) |
| 125 | { |
| 126 | PathAppendA(path, "OpenXcom\\data\\"); |
| 127 | list.push_back(path); |
| 128 | } |
| 129 | |
| 130 | // Get binary directory |
| 131 | if (GetModuleFileNameA(NULL, path, MAX_PATH) != 0) |
| 132 | { |
| 133 | PathRemoveFileSpecA(path); |
| 134 | PathAppendA(path, "data\\"); |
| 135 | list.push_back(path); |
| 136 | } |
| 137 | |
| 138 | // Get working directory |
| 139 | if (GetCurrentDirectoryA(MAX_PATH, path) != 0) |
| 140 | { |
| 141 | PathAppendA(path, "data\\"); |
| 142 | list.push_back(path); |
| 143 | } |
| 144 | #else |
| 145 | char const *home = getHome(); |
| 146 | #ifdef __HAIKU__ |
| 147 | list.push_back("/boot/apps/OpenXcom/data/"); |
| 148 | #endif |
| 149 | char path[MAXPATHLEN]; |
| 150 | |
| 151 | // Get user-specific data folders |
| 152 | if (char const *const xdg_data_home = getenv("XDG_DATA_HOME")) |
| 153 | { |
| 154 | snprintf(path, MAXPATHLEN, "%s/openxcom/data/", xdg_data_home); |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | #ifdef __APPLE__ |
| 159 | snprintf(path, MAXPATHLEN, "%s/Library/Application Support/OpenXcom/data/", home); |
| 160 | #else |
| 161 | snprintf(path, MAXPATHLEN, "%s/.local/share/openxcom/data/", home); |
| 162 | #endif |
| 163 | } |
| 164 | list.push_back(path); |
| 165 | |
| 166 | // Get global data folders |
| 167 | if (char *xdg_data_dirs = getenv("XDG_DATA_DIRS")) |
| 168 | { |
| 169 | char *dir = strtok(xdg_data_dirs, ":"); |