read error handling

This commit is contained in:
Glenn Maynard
2004-06-06 20:21:50 +00:00
parent f8c71ef85c
commit a0bfd8840e
+9 -9
View File
@@ -133,18 +133,18 @@ bool MsdFile::ReadFile( CString sNewPath )
return false; return false;
} }
const int iBufferSize = f.GetFileSize();
// allocate a string to hold the file // 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( (char*) FileString.c_str(), iBytesRead );
ReadBuf(szFileString, iBytesRead);
delete [] szFileString;
return true; return true;
} }