Fix a crash when selecting Cancel after removing an SD/USB device and re-opening the app (#1034)

This commit is contained in:
InfiniteBlueGX 2022-10-24 10:34:55 -05:00 committed by GitHub
parent fb4165fb96
commit 3f4f475f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -677,6 +677,8 @@ bool LoadPrefs()
bool prefFound = false;
char filepath[5][MAXPATHLEN];
int numDevices;
bool sdMounted = false;
bool usbMounted = false;
#ifdef HW_RVL
numDevices = 5;
@ -717,12 +719,14 @@ bool LoadPrefs()
// rename snes9x to snes9xgx
if(GCSettings.LoadMethod == DEVICE_SD)
{
if(ChangeInterface(DEVICE_SD, NOTSILENT) && opendir("sd:/snes9x"))
sdMounted = ChangeInterface(DEVICE_SD, NOTSILENT);
if(sdMounted && opendir("sd:/snes9x"))
rename("sd:/snes9x", "sd:/snes9xgx");
}
else if(GCSettings.LoadMethod == DEVICE_USB)
{
if(ChangeInterface(DEVICE_USB, NOTSILENT) && opendir("usb:/snes9x"))
usbMounted = ChangeInterface(DEVICE_USB, NOTSILENT);
if(usbMounted && opendir("usb:/snes9x"))
rename("usb:/snes9x", "usb:/snes9xgx");
}
else if(GCSettings.LoadMethod == DEVICE_SMB)
@ -751,7 +755,7 @@ bool LoadPrefs()
sprintf(GCSettings.ArtworkFolder, "snes9xgx/artwork");
// attempt to create directories if they don't exist
if(GCSettings.LoadMethod == DEVICE_SD || GCSettings.LoadMethod == DEVICE_USB) {
if((GCSettings.LoadMethod == DEVICE_SD && sdMounted) || (GCSettings.LoadMethod == DEVICE_USB && usbMounted) ) {
char dirPath[MAXPATHLEN];
sprintf(dirPath, "%s%s", pathPrefix[GCSettings.LoadMethod], GCSettings.ScreenshotsFolder);
CreateDirectory(dirPath);
@ -774,6 +778,5 @@ bool LoadPrefs()
bg_music_size = bg_music_ogg_size;
LoadBgMusic();
#endif
return prefFound;
}