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; }