From 571af53ea89e204624d2394a4d6abdc86ae1f9e1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 23 Jun 2004 05:15:47 +0000 Subject: [PATCH] ZIP reading fixes --- 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 f3e3fade49..29811f86aa 100644 --- a/stepmania/src/RageFile.cpp +++ b/stepmania/src/RageFile.cpp @@ -31,7 +31,9 @@ RageFile::RageFile( const RageFile &cpy ) m_Error = cpy.m_Error; m_EOF = cpy.m_EOF; m_FilePos = cpy.m_FilePos; - memcpy( this->m_Buffer, cpy.m_Buffer, cpy.m_BufAvail ); + memcpy( this->m_Buffer, cpy.m_Buffer, sizeof(m_Buffer) ); + m_pBuf = m_Buffer + (cpy.m_pBuf-cpy.m_Buffer); + m_BufAvail = cpy.m_BufAvail; } @@ -243,6 +245,8 @@ int RageFile::Read( void *buffer, size_t bytes ) if( !bytes ) break; + ASSERT( !m_BufAvail ); + /* We need more; either fill the buffer and keep going, or just read directly * into the destination buffer. */ if( bytes >= sizeof(m_Buffer) ) diff --git a/stepmania/src/RageFileDriverDirect.cpp b/stepmania/src/RageFileDriverDirect.cpp index 74b395803e..7d8216212e 100644 --- a/stepmania/src/RageFileDriverDirect.cpp +++ b/stepmania/src/RageFileDriverDirect.cpp @@ -161,7 +161,7 @@ RageFileObj *RageFileObjDirect::Copy( RageFile &p ) const if( ret == NULL ) RageException::Throw("Couldn't reopen \"%s\": %s", path.c_str(), strerror(err) ); - ret->Seek( parent.Tell() ); + ret->Seek( lseek( fd, 0, SEEK_CUR ) ); return ret; }