|
33 | 33 | #pragma comment(lib, "shell32.lib") |
34 | 34 | #pragma comment(lib, "shlwapi.lib") |
35 | 35 | #else |
| 36 | +#include <string.h> |
36 | 37 | #include <stdio.h> |
37 | 38 | #include <stdlib.h> |
38 | 39 | #include <sys/param.h> |
@@ -63,7 +64,7 @@ std::string getDataFile(const std::string &filename) |
63 | 64 |
|
64 | 65 | // Try lowercase and uppercase names |
65 | 66 | struct stat info; |
66 | | - if (stat(newName.c_str(), &info) == 0) |
| 67 | + if (stat(newPath.c_str(), &info) == 0) |
67 | 68 | { |
68 | 69 | return newPath; |
69 | 70 | } |
@@ -159,20 +160,22 @@ std::wstring findDataFolder() |
159 | 160 | } |
160 | 161 | } |
161 | 162 | #else |
162 | | - char path[MAXPATHLEN]; |
| 163 | + wchar_t path[MAXPATHLEN]; |
163 | 164 | struct stat info; |
164 | 165 |
|
165 | 166 | // Check shared directory |
166 | | - path = "/usr/share/openxcom/" |
167 | | - if (stat(path, &info) == 0 && S_ISDIR(info.st_mode)) |
| 167 | + const char* shared = "/usr/share/openxcom/"; |
| 168 | + if (stat(shared, &info) == 0 && S_ISDIR(info.st_mode)) |
168 | 169 | { |
| 170 | + mbstowcs(path, shared, strlen(shared)+1); |
169 | 171 | return path; |
170 | 172 | } |
171 | 173 |
|
172 | 174 | // Check working directory |
173 | | - path = "./DATA/"; |
174 | | - if (stat(path, &info) == 0 && S_ISDIR(info.st_mode)) |
| 175 | + const char* working = "./DATA/"; |
| 176 | + if (stat(working, &info) == 0 && S_ISDIR(info.st_mode)) |
175 | 177 | { |
| 178 | + mbstowcs(path, working, strlen(working)+1); |
176 | 179 | return path; |
177 | 180 | } |
178 | 181 | #endif |
@@ -220,24 +223,27 @@ std::wstring findUserFolder() |
220 | 223 | } |
221 | 224 | } |
222 | 225 | #else |
223 | | - char path[MAXPATHLEN]; |
| 226 | + wchar_t path[MAXPATHLEN]; |
224 | 227 | struct stat info; |
225 | | - |
| 228 | + |
226 | 229 | // Check HOME directory |
227 | 230 | char *homedir = getenv("HOME"); |
228 | 231 | if (homedir) |
229 | 232 | { |
230 | | - snprintf(path, MAXPATHLEN, "%s/.openxcom/", homedir); |
231 | | - if (stat(path, &info) == 0 && S_ISDIR(info.st_mode)) |
| 233 | + char homePath[MAXPATHLEN]; |
| 234 | + snprintf(homePath, MAXPATHLEN, "%s/.openxcom/", homedir); |
| 235 | + if (stat(homePath, &info) == 0 && S_ISDIR(info.st_mode)) |
232 | 236 | { |
| 237 | + mbstowcs(path, homePath, strlen(homePath)+1); |
233 | 238 | return path; |
234 | 239 | } |
235 | 240 | } |
236 | 241 |
|
237 | 242 | // Check working directory |
238 | | - path = "./USER/"; |
239 | | - if (stat(path, &info) == 0 && S_ISDIR(info.st_mode)) |
| 243 | + const char* working = "./USER/"; |
| 244 | + if (stat(working, &info) == 0 && S_ISDIR(info.st_mode)) |
240 | 245 | { |
| 246 | + mbstowcs(path, working, strlen(working)+1); |
241 | 247 | return path; |
242 | 248 | } |
243 | 249 | #endif |
|
0 commit comments