| 301 | } |
| 302 | |
| 303 | bool MakeFilePath(char filepath[], int type, char * filename, int filenum) |
| 304 | { |
| 305 | char file[512]; |
| 306 | char folder[1024]; |
| 307 | char ext[4]; |
| 308 | char temppath[MAXPATHLEN]; |
| 309 | |
| 310 | if(type == FILE_ROM) |
| 311 | { |
| 312 | // Check path length |
| 313 | if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN) |
| 314 | { |
| 315 | ErrorPrompt("Maximum filepath length reached!"); |
| 316 | filepath[0] = 0; |
| 317 | return false; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | sprintf(temppath, "%s%s",browser.dir,browserList[browser.selIndex].filename); |
| 322 | } |
| 323 | } |
| 324 | else if (type == FILE_BORDER_PNG) |
| 325 | { |
| 326 | const char* loadedpath = filename; |
| 327 | if (loadedpath == NULL) loadedpath = "default"; |
| 328 | // Ensure that loadedname contains only the filename, not the path |
| 329 | const char* loadedname = strrchr(loadedpath, '/'); |
| 330 | if (loadedname == NULL) loadedname = loadedpath; |
| 331 | |
| 332 | // Check path length |
| 333 | if ((strlen(pathPrefix[GCSettings.LoadMethod]) + strlen(GCSettings.BorderFolder) + strlen(loadedname)) >= MAXPATHLEN) { |
| 334 | ErrorPrompt("Maximum filepath length reached!"); |
| 335 | filepath[0] = 0; |
| 336 | return false; |
| 337 | } |
| 338 | |
| 339 | StripExt(file, loadedname); |
| 340 | sprintf(temppath, "%s%s/%s.png", pathPrefix[GCSettings.LoadMethod], GCSettings.BorderFolder, file); |
| 341 | } |
| 342 | else |
| 343 | { |
| 344 | if(GCSettings.SaveMethod == DEVICE_AUTO) |
| 345 | return false; |
| 346 | |
| 347 | switch(type) |
| 348 | { |
| 349 | case FILE_SRAM: |
| 350 | case FILE_STATE: |
| 351 | sprintf(folder, GCSettings.SaveFolder); |
| 352 | |
| 353 | if(type == FILE_SRAM) sprintf(ext, "sav"); |
| 354 | else sprintf(ext, "sgm"); |
| 355 | |
| 356 | if(filenum >= -1) |
| 357 | { |
| 358 | if(filenum == -1) |
| 359 | sprintf(file, "%s.%s", filename, ext); |
| 360 | else if(filenum == 0) |
no test coverage detected