MCPcopy Create free account
hub / github.com/dborth/vbagx / MakeFilePath

Function MakeFilePath

source/filebrowser.cpp:303–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303bool 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)

Callers 6

GetFirstZipFilenameFunction · 0.85
LoadBatteryOrStateAutoFunction · 0.85
SaveBatteryOrStateAutoFunction · 0.85
LoadGBROMFunction · 0.85
MenuGameSavesFunction · 0.85
VMCPULoadROMFunction · 0.85

Calls 3

ErrorPromptFunction · 0.85
StripExtFunction · 0.85
CleanupPathFunction · 0.85

Tested by

no test coverage detected