diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index cf544ef2f2..c48985cdc0 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -308,20 +308,20 @@ void Course::Save() { ASSERT( !m_bIsAutogen ); - FILE* fp = fopen( m_sPath, "w" ); - if( fp == NULL ) + RageFile f; + if( !f.Open( m_sPath, RageFile::WRITE ) ) { - LOG->Warn( "Could not write course file '%s'.", m_sPath.c_str() ); + LOG->Warn( "Could not write course file '%s': %s", m_sPath.c_str(), f.GetError().c_str() ); return; } - fprintf( fp, "#COURSE:%s;\n", m_sName.c_str() ); + f.PutLine( ssprintf("#COURSE:%s;", m_sName.c_str()) ); if( m_bRepeat ) - fprintf( fp, "#REPEAT:YES;\n" ); + f.PutLine( "#REPEAT:YES;" ); if( m_iLives != -1 ) - fprintf( fp, "#LIVES:%i;\n", m_iLives ); + f.PutLine( ssprintf("#LIVES:%i;", m_iLives) ); if( m_iMeter != -1 ) - fprintf( fp, "#METER:%i;\n", m_iMeter ); + f.PutLine( ssprintf("#METER:%i;", m_iMeter) ); for( unsigned i=0; i -#if defined(WIN32) -#include -#endif -#if !defined(O_BINARY) -#define O_BINARY 0 -#endif -#include -#include +#include "RageFile.h" void MsdFile::AddParam( char *buf, int len ) { @@ -143,22 +134,22 @@ void MsdFile::ReadBuf( char *buf, int len ) bool MsdFile::ReadFile( CString sNewPath ) { error = ""; - int fd; + RageFile f; /* Open a file. */ - if( (fd = open(sNewPath, O_RDONLY|O_BINARY, 0)) == -1 ) + if( !f.Open( sNewPath ) ) { - error = strerror(errno); + error = f.GetError(); return false; } + /* XXX: f.GetFileSizeInBytes() */ int iBufferSize = GetFileSizeInBytes(sNewPath); // allocate a string to hold the file char* szFileString = new char[iBufferSize]; - int iBytesRead = read( fd, szFileString, iBufferSize ); - close( fd ); + int iBytesRead = f.Read( szFileString, iBufferSize ); ASSERT( iBufferSize >= iBytesRead );