test for error when writing Preferences.ini
This commit is contained in:
@@ -1439,3 +1439,5 @@ Open the preferences file to make changes by hand.=Open the preferences file to
|
|||||||
StepMania Tools Main Menu=StepMania Tools Main Menu
|
StepMania Tools Main Menu=StepMania Tools Main Menu
|
||||||
Troubleshooting=Troubleshooting
|
Troubleshooting=Troubleshooting
|
||||||
|
|
||||||
|
[ChangeGameSettings]
|
||||||
|
Error writing file '%s': %s=Error writing file '%s': %s
|
||||||
@@ -80,7 +80,9 @@ bool IniFile::WriteFile( const RString &sPath ) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IniFile::WriteFile( f );
|
bool bSuccess = IniFile::WriteFile( f );
|
||||||
|
f.Close();
|
||||||
|
return bSuccess && !f.GetError().empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IniFile::WriteFile( RageFileBasic &f ) const
|
bool IniFile::WriteFile( RageFileBasic &f ) const
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "SpecialFiles.h"
|
#include "SpecialFiles.h"
|
||||||
#include ".\changegamesettings.h"
|
#include ".\changegamesettings.h"
|
||||||
#include "archutils/Win32/DialogUtil.h"
|
#include "archutils/Win32/DialogUtil.h"
|
||||||
|
#include "LocalizedString.h"
|
||||||
|
#include "RageUtil.h"
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#define new DEBUG_NEW
|
#define new DEBUG_NEW
|
||||||
@@ -106,6 +108,7 @@ BOOL ChangeGameSettings::OnInitDialog()
|
|||||||
// EXCEPTION: OCX Property Pages should return FALSE
|
// EXCEPTION: OCX Property Pages should return FALSE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LocalizedString ERROR_WRITING_FILE( "ChangeGameSettings", "Error writing file '%s': %s" );
|
||||||
void ChangeGameSettings::OnOK()
|
void ChangeGameSettings::OnOK()
|
||||||
{
|
{
|
||||||
// TODO: Add extra validation here
|
// TODO: Add extra validation here
|
||||||
@@ -137,7 +140,11 @@ void ChangeGameSettings::OnOK()
|
|||||||
ini.SetValue( "Options", "ShowLogWindow", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) );
|
ini.SetValue( "Options", "ShowLogWindow", BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) );
|
||||||
|
|
||||||
|
|
||||||
ini.WriteFile( SpecialFiles::PREFERENCES_INI_PATH );
|
if( !ini.WriteFile(SpecialFiles::PREFERENCES_INI_PATH) )
|
||||||
|
{
|
||||||
|
RString sError = ssprintf( ERROR_WRITING_FILE.GetValue(), SpecialFiles::PREFERENCES_INI_PATH.c_str(), ini.GetError().c_str() );
|
||||||
|
AfxMessageBox( sError );
|
||||||
|
}
|
||||||
|
|
||||||
CDialog::OnOK();
|
CDialog::OnOK();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user