From b821e8fce47d1dbc8c94448fc3727e58814237a3 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 4 May 2019 16:20:22 +1000 Subject: COMMON: Changed DumpFile & StdIOStream to derive from SeekableWriteStream --- common/file.cpp | 10 ++++++++++ common/file.h | 11 +++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/file.cpp b/common/file.cpp index 5fc4f9012b..9cf554646c 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -219,4 +219,14 @@ bool DumpFile::flush() { int32 DumpFile::pos() const { return _handle->pos(); } +bool DumpFile::seek(int32 offset, int whence) { + SeekableWriteStream *ws = dynamic_cast(_handle); + return ws ? ws->seek(offset, whence) : -1; +} + +int32 DumpFile::size() const { + SeekableWriteStream *ws = dynamic_cast(_handle); + return ws ? ws->size() : -1; +} + } // End of namespace Common diff --git a/common/file.h b/common/file.h index 8ad6249d6d..ea7619b0c4 100644 --- a/common/file.h +++ b/common/file.h @@ -134,7 +134,7 @@ public: * Some design ideas: * - automatically drop all files into dumps/ dir? Might not be desired in all cases */ -class DumpFile : public WriteStream, public NonCopyable { +class DumpFile : public SeekableWriteStream, public NonCopyable { protected: /** File handle to the actual file; 0 if no file is open. */ WriteStream *_handle; @@ -158,11 +158,14 @@ public: bool err() const; void clearErr(); - virtual uint32 write(const void *dataPtr, uint32 dataSize); + virtual uint32 write(const void *dataPtr, uint32 dataSize) override; - virtual bool flush(); + virtual bool flush() override; - virtual int32 pos() const; + virtual int32 pos() const override; + + virtual bool seek(int32 offset, int whence = SEEK_SET) override; + virtual int32 size() const override; }; } // End of namespace Common -- cgit v1.2.3