Prevented that an empty SYSCONF file is saved if it's missing from the config dir.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1228 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-20 15:29:35 +00:00
parent 12a8174446
commit 748da8b464
2 changed files with 30 additions and 21 deletions

View File

@ -69,10 +69,12 @@ CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title,
{ {
fread(m_SYSCONF, 1, 0x4000, pStream); fread(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream); fclose(pStream);
m_bSysconfOK = true;
} }
else else
{ {
PanicAlert("Could not read " FULL_CONFIG_DIR "SYSCONF"); PanicAlert("Could not read " FULL_CONFIG_DIR "SYSCONF. Please recover the SYSCONF file to that location.");
m_bSysconfOK = false;
} }
CreateGUIControls(); CreateGUIControls();
@ -301,28 +303,33 @@ void CConfigMain::OnClose(wxCloseEvent& WXUNUSED (event))
{ {
Destroy(); Destroy();
// Save Wii SYSCONF twice so that we can keep game specific settings for it /* First check that we did successfully populate m_SYSCONF earlier, otherwise don't
pStream = NULL; save anything, it will be a corrupted file */
pStream = fopen(FULL_CONFIG_DIR "SYSCONF", "wb"); if(m_bSysconfOK)
if (pStream != NULL)
{ {
fwrite(m_SYSCONF, 1, 0x4000, pStream); // Save Wii SYSCONF twice so that we can keep game specific settings for it
fclose(pStream); pStream = NULL;
} pStream = fopen(FULL_CONFIG_DIR "SYSCONF", "wb");
else if (pStream != NULL)
{ {
PanicAlert("Could not write to SYSCONF"); fwrite(m_SYSCONF, 1, 0x4000, pStream);
} fclose(pStream);
}
else
{
PanicAlert("Could not write to SYSCONF");
}
pStream = fopen(FULL_WII_USER_DIR "shared2/sys/SYSCONF", "wb"); pStream = fopen(FULL_WII_USER_DIR "shared2/sys/SYSCONF", "wb");
if (pStream != NULL) if (pStream != NULL)
{ {
fwrite(m_SYSCONF, 1, 0x4000, pStream); fwrite(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream); fclose(pStream);
} }
else else
{ {
PanicAlert("Could not write to shared2/sys/SYSCONF"); PanicAlert("Could not write to shared2/sys/SYSCONF");
}
} }
// save the config... dolphin crashes by far to often to save the settings on closing only // save the config... dolphin crashes by far to often to save the settings on closing only

View File

@ -88,6 +88,8 @@ class CConfigMain
FILE* pStream; FILE* pStream;
u8 m_SYSCONF[0x4000]; u8 m_SYSCONF[0x4000];
bool m_bSysconfOK;
enum enum
{ {
BT_DINF = 0x0044, BT_DINF = 0x0044,