error handling cleanup
This commit is contained in:
@@ -134,9 +134,9 @@ bool RageFileSink::IsolatedFlush(bool hardFlush, bool blocking)
|
|||||||
if (!m_file.IsOpen())
|
if (!m_file.IsOpen())
|
||||||
throw Err("FileSink: output stream not opened");
|
throw Err("FileSink: output stream not opened");
|
||||||
|
|
||||||
m_file.Flush();
|
|
||||||
if( !m_file.IsGood() )
|
if( m_file.Flush() == -1 )
|
||||||
throw WriteErr();
|
throw WriteErr( m_file );
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -146,13 +146,12 @@ unsigned int RageFileSink::Put2(const byte *inString, unsigned int length, int m
|
|||||||
if (!m_file.IsOpen())
|
if (!m_file.IsOpen())
|
||||||
throw Err("FileSink: output stream not opened");
|
throw Err("FileSink: output stream not opened");
|
||||||
|
|
||||||
m_file.Write((const char *)inString, length);
|
if( m_file.Write((const char *)inString, length) == -1 )
|
||||||
|
throw WriteErr( m_file );
|
||||||
|
|
||||||
if (messageEnd)
|
if (messageEnd)
|
||||||
m_file.Flush();
|
if( m_file.Flush() == -1 )
|
||||||
|
throw WriteErr( m_file );
|
||||||
if( !m_file.IsGood() )
|
|
||||||
throw WriteErr();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,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("FileSink: error opening file for writing: " + filename) {}};
|
class OpenErr : public Err {public: OpenErr(const std::string &filename) : Err("FileSink: error opening file for writing: " + filename) {}};
|
||||||
class WriteErr : public Err {public: WriteErr() : Err("FileSink: error writing file") {}};
|
struct WriteErr : public Err { WriteErr(const RageFile &f) : Err("RageFileSink(" + f.GetPath() + "): write error: " + f.GetError()) {}};
|
||||||
|
|
||||||
RageFileSink() {}
|
RageFileSink() {}
|
||||||
RageFileSink(const char *filename, bool binary=true)
|
RageFileSink(const char *filename, bool binary=true)
|
||||||
|
|||||||
Reference in New Issue
Block a user