forked from mirror/openmw-tes3mp
Added Stream::flush()
This commit is contained in:
parent
71366d9a07
commit
d3f0932b20
4 changed files with 12 additions and 4 deletions
|
@ -31,6 +31,7 @@ class PureFilter : public Stream
|
|||
|
||||
size_t read(void *buf, size_t count) { return src->read(buf, count); }
|
||||
size_t write(const void *buf, size_t count) { return src->write(buf,count); }
|
||||
void flush() { src->flush(); }
|
||||
void seek(size_t pos) { src->seek(pos); }
|
||||
size_t tell() const { return src->tell(); }
|
||||
size_t size() const { return src->size(); }
|
||||
|
|
|
@ -72,6 +72,7 @@ class SliceStream : public Stream
|
|||
bool eof() const { return pos == length; }
|
||||
size_t tell() const { return pos; }
|
||||
size_t size() const { return length; }
|
||||
void flush() { src->flush(); }
|
||||
|
||||
const void *getPtr() { return getPtr(0, length); }
|
||||
const void *getPtr(size_t size)
|
||||
|
|
|
@ -37,13 +37,16 @@ class StdOStream : public Stream
|
|||
inf->write((const char*)buf, len);
|
||||
if(inf->fail())
|
||||
fail("error writing to stream");
|
||||
|
||||
// Unfortunately, stupid std::ostream doesn't have a pcount() to
|
||||
// match gcount() for input. In general the std::iostream system
|
||||
// is an idiotically designed stream library.
|
||||
// Just return len, but that is ok. The only cases where we would
|
||||
// return less than len is when an error occured.
|
||||
return len;
|
||||
}
|
||||
|
||||
void flush()
|
||||
{
|
||||
inf->flush();
|
||||
}
|
||||
|
||||
void seek(size_t pos)
|
||||
{
|
||||
inf->seekp(pos);
|
||||
|
|
|
@ -52,6 +52,9 @@ class Stream
|
|||
*/
|
||||
virtual size_t write(const void *buf, size_t count) { assert(0); return 0; }
|
||||
|
||||
/// Flush an output stream. Does nothing for non-writing streams.
|
||||
virtual void flush() {}
|
||||
|
||||
/// Seek to an absolute position in this stream. Not all streams are
|
||||
/// seekable.
|
||||
virtual void seek(size_t pos) = 0;
|
||||
|
|
Loading…
Reference in a new issue