From 748da8b464cbb45d8b4ab3335a177706c719d0b5 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 20 Nov 2008 15:29:35 +0000 Subject: [PATCH] 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 --- Source/Core/DolphinWX/Src/ConfigMain.cpp | 49 ++++++++++++++---------- Source/Core/DolphinWX/Src/ConfigMain.h | 2 + 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index b9c72c8f92..5d67d1500b 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -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 diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h index e9874c0d2d..11c803cc0b 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -88,6 +88,8 @@ class CConfigMain FILE* pStream; u8 m_SYSCONF[0x4000]; + bool m_bSysconfOK; + enum { BT_DINF = 0x0044,