fixed crashes when ini, log, and cache files are read-only
This commit is contained in:
@@ -92,6 +92,10 @@ bool IniFile::ReadFile()
|
|||||||
void IniFile::WriteFile()
|
void IniFile::WriteFile()
|
||||||
{
|
{
|
||||||
FILE* fp = fopen( path, "w" );
|
FILE* fp = fopen( path, "w" );
|
||||||
|
|
||||||
|
if( fp == NULL )
|
||||||
|
return;
|
||||||
|
|
||||||
for (keymap::const_iterator k = keys.begin(); k != keys.end(); ++k)
|
for (keymap::const_iterator k = keys.begin(); k != keys.end(); ++k)
|
||||||
{
|
{
|
||||||
if (k->second.empty())
|
if (k->second.empty())
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "Notes.h"
|
#include "Notes.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "GameManager.h"
|
#include "GameManager.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
void NotesWriterSM::WriteGlobalTags(FILE *fp, const Song &out)
|
void NotesWriterSM::WriteGlobalTags(FILE *fp, const Song &out)
|
||||||
{
|
{
|
||||||
@@ -95,7 +96,10 @@ bool NotesWriterSM::Write(CString sPath, const Song &out, bool bSavingCache)
|
|||||||
|
|
||||||
FILE* fp = fopen( sPath, "w" );
|
FILE* fp = fopen( sPath, "w" );
|
||||||
if( fp == NULL )
|
if( fp == NULL )
|
||||||
RageException::Throw( "Error opening song file '%s' for writing.", sPath.GetString() );
|
{
|
||||||
|
LOG->Warn( "Error opening song file '%s' for writing.", sPath.GetString() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
WriteGlobalTags(fp, out);
|
WriteGlobalTags(fp, out);
|
||||||
if(bSavingCache) {
|
if(bSavingCache) {
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ RageLog::~RageLog()
|
|||||||
{
|
{
|
||||||
Flush();
|
Flush();
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
fclose( m_fileLog );
|
if( m_fileLog )
|
||||||
|
fclose( m_fileLog );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageLog::ShowConsole()
|
void RageLog::ShowConsole()
|
||||||
@@ -68,7 +69,8 @@ void RageLog::Trace( const char *fmt, ...)
|
|||||||
CString sBuff = vssprintf( fmt, va );
|
CString sBuff = vssprintf( fmt, va );
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
fprintf( m_fileLog, "%s\n", sBuff.GetString() );
|
if( m_fileLog )
|
||||||
|
fprintf( m_fileLog, "%s\n", sBuff.GetString() );
|
||||||
printf( "%s\n", sBuff.GetString() );
|
printf( "%s\n", sBuff.GetString() );
|
||||||
CrashLog(sBuff);
|
CrashLog(sBuff);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user