propagate file driver errors normally
This commit is contained in:
@@ -91,6 +91,9 @@ int RageFile::FillBuf()
|
|||||||
ASSERT_M( iBufAvail >= 0, ssprintf("%p, %p, %i", m_pBuf, m_Buffer, (int) sizeof(m_Buffer) ) );
|
ASSERT_M( iBufAvail >= 0, ssprintf("%p, %p, %i", m_pBuf, m_Buffer, (int) sizeof(m_Buffer) ) );
|
||||||
const int size = m_File->Read( m_pBuf+m_BufAvail, iBufAvail );
|
const int size = m_File->Read( m_pBuf+m_BufAvail, iBufAvail );
|
||||||
|
|
||||||
|
if( size == -1 )
|
||||||
|
SetError( m_File->GetError() );
|
||||||
|
|
||||||
if( size > 0 )
|
if( size > 0 )
|
||||||
m_BufAvail += size;
|
m_BufAvail += size;
|
||||||
|
|
||||||
@@ -245,8 +248,11 @@ int RageFile::Read( void *buffer, size_t bytes )
|
|||||||
/* We have a lot more to read, so don't waste time copying it into the
|
/* We have a lot more to read, so don't waste time copying it into the
|
||||||
* buffer. */
|
* buffer. */
|
||||||
int FromFile = m_File->Read( buffer, bytes );
|
int FromFile = m_File->Read( buffer, bytes );
|
||||||
if( FromFile < 0 )
|
if( FromFile == -1 )
|
||||||
return FromFile;
|
{
|
||||||
|
SetError( m_File->GetError() );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if( FromFile == 0 )
|
if( FromFile == 0 )
|
||||||
m_EOF = true;
|
m_EOF = true;
|
||||||
ret += FromFile;
|
ret += FromFile;
|
||||||
@@ -279,7 +285,10 @@ int RageFile::Seek( int offset )
|
|||||||
|
|
||||||
int pos = m_File->Seek( offset );
|
int pos = m_File->Seek( offset );
|
||||||
if( pos == -1 )
|
if( pos == -1 )
|
||||||
|
{
|
||||||
|
SetError( m_File->GetError() );
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
m_FilePos = pos;
|
m_FilePos = pos;
|
||||||
return pos;
|
return pos;
|
||||||
@@ -335,7 +344,13 @@ int RageFile::Write( const void *buffer, size_t bytes )
|
|||||||
if( !(m_Mode&WRITE) )
|
if( !(m_Mode&WRITE) )
|
||||||
RageException::Throw("\"%s\" is not open for writing", GetPath().c_str());
|
RageException::Throw("\"%s\" is not open for writing", GetPath().c_str());
|
||||||
|
|
||||||
return m_File->Write( buffer, bytes );
|
int iRet = m_File->Write( buffer, bytes );
|
||||||
|
if( iRet == -1 )
|
||||||
|
{
|
||||||
|
SetError( m_File->GetError() );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -344,7 +359,10 @@ int RageFile::Write( const void *buffer, size_t bytes, int nmemb )
|
|||||||
/* Simple write. We never return partial writes. */
|
/* Simple write. We never return partial writes. */
|
||||||
int ret = Write( buffer, bytes*nmemb ) / bytes;
|
int ret = Write( buffer, bytes*nmemb ) / bytes;
|
||||||
if( ret == -1 )
|
if( ret == -1 )
|
||||||
|
{
|
||||||
|
SetError( m_File->GetError() );
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
return ret / bytes;
|
return ret / bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +374,13 @@ int RageFile::Flush()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_File->Flush();
|
int iRet = m_File->Flush();
|
||||||
|
if( iRet == -1 )
|
||||||
|
{
|
||||||
|
SetError( m_File->GetError() );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RageFile::Read( void *buffer, size_t bytes, int nmemb )
|
int RageFile::Read( void *buffer, size_t bytes, int nmemb )
|
||||||
|
|||||||
@@ -8,11 +8,6 @@ RageFileDriver::~RageFileDriver()
|
|||||||
delete FDB;
|
delete FDB;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageFileObj::SetError( const CString &err )
|
|
||||||
{
|
|
||||||
parent.SetError( err );
|
|
||||||
}
|
|
||||||
|
|
||||||
int RageFileDriver::GetPathValue( const CString &path )
|
int RageFileDriver::GetPathValue( const CString &path )
|
||||||
{
|
{
|
||||||
vector<CString> parts;
|
vector<CString> parts;
|
||||||
|
|||||||
@@ -35,12 +35,14 @@ class RageFileObj
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
RageFile &parent;
|
RageFile &parent;
|
||||||
void SetError( const CString &err );
|
void SetError( const CString &sErr ) { m_sError = sErr; }
|
||||||
|
CString m_sError;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RageFileObj( RageFile &p ): parent(p) { }
|
RageFileObj( RageFile &p ): parent(p) { }
|
||||||
virtual ~RageFileObj() { }
|
virtual ~RageFileObj() { }
|
||||||
|
|
||||||
|
CString GetError() const { return m_sError; }
|
||||||
// virtual CString RealPath() const { return parent->GetPath(); }
|
// virtual CString RealPath() const { return parent->GetPath(); }
|
||||||
|
|
||||||
virtual int Seek( int offset ) = 0;
|
virtual int Seek( int offset ) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user