simplify error check
This commit is contained in:
@@ -43,7 +43,7 @@ unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned
|
|||||||
if (m_waiting)
|
if (m_waiting)
|
||||||
goto output;
|
goto output;
|
||||||
|
|
||||||
while( size && m_file.IsGood() )
|
while( size && !m_file.AtEOF() )
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
unsigned int spaceSize = 1024;
|
unsigned int spaceSize = 1024;
|
||||||
@@ -51,7 +51,7 @@ unsigned int RageFileStore::TransferTo2(BufferedTransformation &target, unsigned
|
|||||||
|
|
||||||
m_len = m_file.Read( (char *)m_space, STDMIN(size, (unsigned long)spaceSize));
|
m_len = m_file.Read( (char *)m_space, STDMIN(size, (unsigned long)spaceSize));
|
||||||
if( m_len == -1 )
|
if( m_len == -1 )
|
||||||
throw ReadErr();
|
throw ReadErr( m_file );
|
||||||
}
|
}
|
||||||
unsigned int blockedBytes;
|
unsigned int blockedBytes;
|
||||||
output:
|
output:
|
||||||
@@ -63,9 +63,6 @@ output:
|
|||||||
transferBytes += m_len;
|
transferBytes += m_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_file.IsGood() && !m_file.AtEOF())
|
|
||||||
throw ReadErr();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
Err(const std::string &s) : Exception(IO_ERROR, s) {}
|
Err(const std::string &s) : Exception(IO_ERROR, s) {}
|
||||||
};
|
};
|
||||||
class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileStore: error opening file for reading: " + filename) {}};
|
class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileStore: error opening file for reading: " + filename) {}};
|
||||||
class ReadErr : public Err {public: ReadErr() : Err("FileStore: error reading file") {}};
|
struct ReadErr : public Err { ReadErr(const RageFile &f) : Err("RageFileStore(" + f.GetPath() + "): read error: " + f.GetError() ) {}};
|
||||||
|
|
||||||
RageFileStore() {}
|
RageFileStore() {}
|
||||||
RageFileStore(const char *filename)
|
RageFileStore(const char *filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user