ZIP reading fixes

This commit is contained in:
Glenn Maynard
2004-06-23 05:15:47 +00:00
parent 1a78bf45bc
commit 571af53ea8
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -31,7 +31,9 @@ RageFile::RageFile( const RageFile &cpy )
m_Error = cpy.m_Error; m_Error = cpy.m_Error;
m_EOF = cpy.m_EOF; m_EOF = cpy.m_EOF;
m_FilePos = cpy.m_FilePos; 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; m_BufAvail = cpy.m_BufAvail;
} }
@@ -243,6 +245,8 @@ int RageFile::Read( void *buffer, size_t bytes )
if( !bytes ) if( !bytes )
break; break;
ASSERT( !m_BufAvail );
/* We need more; either fill the buffer and keep going, or just read directly /* We need more; either fill the buffer and keep going, or just read directly
* into the destination buffer. */ * into the destination buffer. */
if( bytes >= sizeof(m_Buffer) ) if( bytes >= sizeof(m_Buffer) )
+1 -1
View File
@@ -161,7 +161,7 @@ RageFileObj *RageFileObjDirect::Copy( RageFile &p ) const
if( ret == NULL ) if( ret == NULL )
RageException::Throw("Couldn't reopen \"%s\": %s", path.c_str(), strerror(err) ); 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; return ret;
} }