From a0bfd8840e9909ea53c17b5772a937952d2474ff Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 6 Jun 2004 20:21:50 +0000 Subject: [PATCH] read error handling --- stepmania/src/MsdFile.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stepmania/src/MsdFile.cpp b/stepmania/src/MsdFile.cpp index b1a81199d6..594f43fa37 100644 --- a/stepmania/src/MsdFile.cpp +++ b/stepmania/src/MsdFile.cpp @@ -133,18 +133,18 @@ bool MsdFile::ReadFile( CString sNewPath ) return false; } - const int iBufferSize = f.GetFileSize(); - // allocate a string to hold the file - char* szFileString = new char[iBufferSize]; + CString FileString; + FileString.reserve( f.GetFileSize() ); - int iBytesRead = f.Read( szFileString, iBufferSize ); + int iBytesRead = f.Read( FileString ); + if( iBytesRead == -1 ) + { + error = f.GetError(); + return false; + } - ASSERT( iBufferSize >= iBytesRead ); - - ReadBuf(szFileString, iBytesRead); - - delete [] szFileString; + ReadBuf( (char*) FileString.c_str(), iBytesRead ); return true; }