MCPcopy Create free account
hub / github.com/TASEmulators/fceux / OpenMemwatchRecentFile

Function OpenMemwatchRecentFile

src/drivers/win/memwatch.cpp:605–661  ·  view source on GitHub ↗

Loads a recent file given the recent files array number(0-4)

Source from the content-addressed store, hash-verified

603
604//Loads a recent file given the recent files array number(0-4)
605void OpenMemwatchRecentFile(int memwRFileNumber)
606{
607 if (memwRFileNumber > MEMW_MAX_NUMBER_OF_RECENT_FILES) return; //just in case
608
609 char* x = memw_recent_files[memwRFileNumber];
610 if (x == NULL) return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy)
611 char watchfcontents[2048];
612
613 FILE *fp=FCEUD_UTF8fopen(x,"r"); //Open the recent file
614 if (fp) //Check if file opening was successful, if not, abort
615 {
616 strcpy(memwLastFilename,x);
617 if (memwRFileNumber != 0) //Change order of recent files if not most recent
618 MemwAddRecentFile(x);
619 int i,j;
620 for(i=0;i<NUMWATCHES;i++)
621 {
622 fscanf(fp, "%s ", watchfcontents); //Reads contents of newly opened file
623 for(j = 0; j < ADDRESSLENGTH; j++)
624 addresses[i][j] = watchfcontents[j];
625 fscanf(fp, "%s\n", watchfcontents);
626 for(j = 0; j < LABELLENGTH; j++)
627 labels[i][j] = watchfcontents[j];
628
629 //Replace dummy strings with empty strings
630 if(addresses[i][0] == '|')
631 {
632 addresses[i][0] = 0;
633 }
634 if(labels[i][0] == '|')
635 {
636 labels[i][0] = 0;
637 }
638 PutInSpaces(i);
639
640 int templl = LABELLENGTH - 1;
641 int tempal = ADDRESSLENGTH - 1;
642 addresses[i][tempal] = 0;
643 labels[i][templl] = 0; //just in case
644
645 SetDlgItemText(hwndMemWatch,MW_VAL [i],(LPTSTR) "---");
646 SetDlgItemText(hwndMemWatch,MW_ADDR[i],(LPTSTR) addresses[i]);
647 SetDlgItemText(hwndMemWatch,MW_NAME[i],(LPTSTR) labels[i]);
648 }
649 fclose(fp); //Close the file
650 fileChanged = false; //Flag that the memwatch file has not been changed since last save
651 }
652 else //Opening fp failed
653 {
654 int result = MessageBox(hwndMemWatch,"Remove from list?", "Could Not Open Recent File", MB_YESNO);
655 if (result == IDYES)
656 {
657 RemoveRecentItem(memwRFileNumber, memw_recent_files, MEMW_MAX_NUMBER_OF_RECENT_FILES);
658 UpdateMemw_RMenu(memwrecentmenu, memw_recent_files, ID_FILE_RECENT, MEMW_MENU_FIRST_RECENT_FILE);
659 }
660 }
661}
662

Callers 2

MemWatchCallBFunction · 0.85
CreateMemWatchFunction · 0.85

Calls 5

MemwAddRecentFileFunction · 0.85
PutInSpacesFunction · 0.85
RemoveRecentItemFunction · 0.85
UpdateMemw_RMenuFunction · 0.85
FCEUD_UTF8fopenFunction · 0.70

Tested by

no test coverage detected