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);
fclose(pStream);
m_bSysconfOK = true;
}
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();
@ -301,28 +303,33 @@ void CConfigMain::OnClose(wxCloseEvent& WXUNUSED (event))
{
Destroy();
// Save Wii SYSCONF twice so that we can keep game specific settings for it
pStream = NULL;
pStream = fopen(FULL_CONFIG_DIR "SYSCONF", "wb");
if (pStream != NULL)
/* First check that we did successfully populate m_SYSCONF earlier, otherwise don't
save anything, it will be a corrupted file */
if(m_bSysconfOK)
{
fwrite(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream);
}
else
{
PanicAlert("Could not write to SYSCONF");
}
// Save Wii SYSCONF twice so that we can keep game specific settings for it
pStream = NULL;
pStream = fopen(FULL_CONFIG_DIR "SYSCONF", "wb");
if (pStream != NULL)
{
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");
if (pStream != NULL)
{
fwrite(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream);
}
else
{
PanicAlert("Could not write to shared2/sys/SYSCONF");
pStream = fopen(FULL_WII_USER_DIR "shared2/sys/SYSCONF", "wb");
if (pStream != NULL)
{
fwrite(m_SYSCONF, 1, 0x4000, pStream);
fclose(pStream);
}
else
{
PanicAlert("Could not write to shared2/sys/SYSCONF");
}
}
// 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;
u8 m_SYSCONF[0x4000];
bool m_bSysconfOK;
enum
{
BT_DINF = 0x0044,