From 12c21c302cd65260e6c11dd860b9ce5fa024920f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 6 Oct 2004 04:25:27 +0000 Subject: [PATCH] error checks to trace https://sourceforge.net/tracker/index.php?func=detail&aid=1035264&group_id=37892&atid=421366 fix error message --- stepmania/src/RageFile.cpp | 6 ++++-- stepmania/src/RageFileDriverDirect.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageFile.cpp b/stepmania/src/RageFile.cpp index 15b4d59ae4..af19772d14 100644 --- a/stepmania/src/RageFile.cpp +++ b/stepmania/src/RageFile.cpp @@ -333,7 +333,9 @@ int RageFile::GetFileSize() const /* GetFileSize() may need to do non-const-like things--the default implementation reads * until the end of file to emulate it. However, it should always restore the state to * the way it was, so pretend it's const. */ - return const_cast(m_File)->GetFileSize(); + int iRet = const_cast(m_File)->GetFileSize(); + ASSERT_M( iRet >= 0, ssprintf("%i", iRet) ); + return iRet; } void RageFile::Rewind() @@ -342,7 +344,7 @@ void RageFile::Rewind() RageException::Throw("\"%s\" is not open.", GetPath().c_str()); if( !(m_Mode&READ) ) - RageException::Throw("\"%s\" is not open for reading; can't GetFileSize", GetPath().c_str()); + RageException::Throw("\"%s\" is not open for reading; can't Rewind", GetPath().c_str()); m_EOF = false; diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index 086a4afb5a..d37d3b59e9 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -372,7 +372,9 @@ int RageFileObjDirect::Seek( int offset ) int RageFileObjDirect::GetFileSize() { const int OldPos = lseek( fd, 0, SEEK_CUR ); + ASSERT_M( OldPos != -1, strerror(errno) ): const int ret = lseek( fd, 0, SEEK_END ); + ASSERT_M( ret!= -1, strerror(errno) ): lseek( fd, OldPos, SEEK_SET ); return ret; }