aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2019-05-04 16:20:22 +1000
committerFilippos Karapetis2019-05-12 11:44:15 +0300
commitb821e8fce47d1dbc8c94448fc3727e58814237a3 (patch)
tree6a463d8b27efed174117e9a3d08f56dcc66c3331
parentf4dacdf34dbbed1869da26ed970bc2f5cf97685e (diff)
downloadscummvm-rg350-b821e8fce47d1dbc8c94448fc3727e58814237a3.tar.gz
scummvm-rg350-b821e8fce47d1dbc8c94448fc3727e58814237a3.tar.bz2
scummvm-rg350-b821e8fce47d1dbc8c94448fc3727e58814237a3.zip
COMMON: Changed DumpFile & StdIOStream to derive from SeekableWriteStream
-rw-r--r--backends/fs/stdiostream.h20
-rw-r--r--common/file.cpp10
-rw-r--r--common/file.h11
3 files changed, 27 insertions, 14 deletions
diff --git a/backends/fs/stdiostream.h b/backends/fs/stdiostream.h
index f2495feac8..c3646b422a 100644
--- a/backends/fs/stdiostream.h
+++ b/backends/fs/stdiostream.h
@@ -28,7 +28,7 @@
#include "common/stream.h"
#include "common/str.h"
-class StdioStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable {
+class StdioStream : public Common::SeekableReadStream, public Common::SeekableWriteStream, public Common::NonCopyable {
protected:
/** File handle to the actual file. */
void *_handle;
@@ -43,17 +43,17 @@ public:
StdioStream(void *handle);
virtual ~StdioStream();
- virtual bool err() const;
- virtual void clearErr();
- virtual bool eos() const;
+ virtual bool err() const override;
+ virtual void clearErr() override;
+ virtual bool eos() const override;
- virtual uint32 write(const void *dataPtr, uint32 dataSize);
- virtual bool flush();
+ virtual uint32 write(const void *dataPtr, uint32 dataSize) override;
+ virtual bool flush() override;
- virtual int32 pos() const;
- virtual int32 size() const;
- virtual bool seek(int32 offs, int whence = SEEK_SET);
- virtual uint32 read(void *dataPtr, uint32 dataSize);
+ virtual int32 pos() const override;
+ virtual int32 size() const override;
+ virtual bool seek(int32 offs, int whence = SEEK_SET) override;
+ virtual uint32 read(void *dataPtr, uint32 dataSize) override;
};
#endif
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<SeekableWriteStream *>(_handle);
+ return ws ? ws->seek(offset, whence) : -1;
+}
+
+int32 DumpFile::size() const {
+ SeekableWriteStream *ws = dynamic_cast<SeekableWriteStream *>(_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