mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
GetSavestateName : Archive support
* Construct ssname from srampath (since rompath has archive name) NOTE: In general, archive name != rom file name !!!!!!!!!! Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
This commit is contained in:
@ -570,15 +570,22 @@ void GetSavestateName(int slot, char* filename, int len)
|
||||
}
|
||||
else
|
||||
{
|
||||
int l = strlen(ROMPath[ROMSlot_NDS]);
|
||||
char *rompath;
|
||||
QString _filename(ROMPath[ROMSlot_NDS]);
|
||||
if(_filename.endsWith(".nds") || _filename.endsWith(".srl") || _filename.endsWith(".dsi"))
|
||||
rompath = ROMPath[ROMSlot_NDS];
|
||||
else
|
||||
rompath = SRAMPath[ROMSlot_NDS]; // If archive, construct ssname from sram file
|
||||
|
||||
int l = strlen(rompath);
|
||||
pos = l;
|
||||
while (ROMPath[ROMSlot_NDS][pos] != '.' && pos > 0) pos--;
|
||||
while (rompath[pos] != '.' && pos > 0) pos--;
|
||||
if (pos == 0) pos = l;
|
||||
|
||||
// avoid buffer overflow. shoddy
|
||||
if (pos > len-5) pos = len-5;
|
||||
|
||||
strncpy(&filename[0], ROMPath[ROMSlot_NDS], pos);
|
||||
strncpy(&filename[0], rompath, pos);
|
||||
}
|
||||
strcpy(&filename[pos], ".ml");
|
||||
filename[pos+3] = '0'+slot;
|
||||
|
Reference in New Issue
Block a user