diff options
Diffstat (limited to 'engines/gob/dataio.h')
-rw-r--r-- | engines/gob/dataio.h | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/engines/gob/dataio.h b/engines/gob/dataio.h index 3ea29c0efe..b30a389865 100644 --- a/engines/gob/dataio.h +++ b/engines/gob/dataio.h @@ -35,7 +35,33 @@ namespace Gob { #define MAX_FILES 30 #define MAX_DATA_FILES 8 -#define MAX_SLOT_COUNT 4 +#define MAX_SLOT_COUNT 8 + +class DataIO; + +class DataStream : public Common::SeekableReadStream { +public: + DataStream(DataIO &io, int16 handle, uint32 dSize, bool dispose = false); + DataStream(byte *buf, uint32 dSize, bool dispose = true); + virtual ~DataStream(); + + virtual uint32 pos() const; + virtual uint32 size() const; + + virtual void seek(int32 offset, int whence = SEEK_SET); + + virtual bool eos() const; + + virtual uint32 read(void *dataPtr, uint32 dataSize); + +private: + DataIO *_io; + int16 _handle; + uint32 _size; + byte *_data; + Common::MemoryReadStream *_stream; + bool _dispose; +}; class DataIO { public: @@ -55,15 +81,11 @@ public: void closeData(int16 handle); int16 openData(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode); - int32 readData(int16 handle, byte *buf, uint16 size); - byte readByte(int16 handle); - uint16 readUint16(int16 handle); - uint32 readUint32(int16 handle); - int32 writeData(int16 handle, byte *buf, uint16 size); - void seekData(int16 handle, int32 pos, int16 from); - uint32 getPos(int16 handle); + DataStream *openAsStream(int16 handle, bool dispose = false); + int32 getDataSize(const char *name); byte *getData(const char *path); + DataStream *getDataStream(const char *path); DataIO(class GobEngine *vm); ~DataIO(); @@ -85,13 +107,20 @@ protected: int16 file_open(const char *path, Common::File::AccessMode mode = Common::File::kFileReadMode); Common::File *file_getHandle(int16 handle); + const Common::File *file_getHandle(int16 handle) const; int16 getChunk(const char *chunkName); char freeChunk(int16 handle); int32 readChunk(int16 handle, byte *buf, uint16 size); int16 seekChunk(int16 handle, int32 pos, int16 from); - uint32 getChunkPos(int16 handle); + uint32 getChunkPos(int16 handle) const; int32 getChunkSize(const char *chunkName); + + uint32 getPos(int16 handle); + void seekData(int16 handle, int32 pos, int16 from); + int32 readData(int16 handle, byte *buf, uint16 size); + +friend class DataStream; }; } // End of namespace Gob |