ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
datafile.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MEDIASTATION_DATAFILE_H
23 #define MEDIASTATION_DATAFILE_H
24 
25 #include "common/file.h"
26 #include "common/stream.h"
27 #include "common/path.h"
28 
29 namespace MediaStation {
30 
31 // A Media Station datafile consists of one or more RIFF-style "subfiles". Aside
32 // from some oddness at the start of the subfile, each subfile is basically
33 // standard sequence of chunks inside a LIST chunk, like you'd see in any RIFF
34 // file. These chunks have special IDs:
35 // - igod: Indicates a chunk that contains metadata about asset(s) in metadata sections.
36 // - a000, where 000 is a string that represents a 3-digit hexadecimal number.
37 // Indicates a chunk that contains actor data (sounds and bitmaps).
38 
40 public:
41  Chunk() = default;
43 
44  uint32 bytesRemaining();
45 
46  uint32 _id = 0;
47  uint32 _length = 0;
48 
49  // ReadStream implementation
50  virtual bool eos() const { return _parentStream->eos(); };
51  virtual bool err() const {return _parentStream->err(); };
52  virtual void clearErr() { _parentStream->clearErr(); };
53  virtual uint32 read(void *dataPtr, uint32 dataSize);
54  virtual int64 pos() const { return _parentStream->pos(); };
55  virtual int64 size() const { return _parentStream->size(); };
56  virtual bool skip(uint32 offset) { return seek(offset, SEEK_CUR); };
57  virtual bool seek(int64 offset, int whence = SEEK_SET);
58 
59 private:
60  Common::SeekableReadStream *_parentStream = nullptr;
61  uint32 _dataStartOffset = 0;
62  uint32 _dataEndOffset = 0;
63 };
64 
65 class Subfile {
66 public:
67  Subfile() = default;
69 
70  Chunk nextChunk();
71  bool atEnd();
72 
73  Chunk _currentChunk;
74  uint32 _rate;
75 
76 private:
77  Common::SeekableReadStream *_stream = nullptr;
78  Chunk _rootChunk;
79 };
80 
81 class Datafile : public Common::File {
82 public:
83  Datafile(const Common::Path &path);
84 
85  Subfile getNextSubfile();
86 };
87 
88 } // End of namespace MediaStation
89 
90 #endif
virtual void clearErr()
Definition: datafile.h:52
virtual int64 size() const
Definition: datafile.h:55
virtual int64 size() const =0
virtual int64 pos() const =0
Definition: datafile.h:81
virtual bool eos() const
Definition: datafile.h:50
virtual bool err() const
Definition: stream.h:61
Definition: asset.h:33
virtual void clearErr()
Definition: stream.h:71
virtual bool eos() const =0
Definition: datafile.h:39
virtual int64 pos() const
Definition: datafile.h:54
Definition: path.h:52
Definition: stream.h:745
virtual uint32 read(void *dataPtr, uint32 dataSize)
Definition: file.h:47
virtual bool skip(uint32 offset)
Definition: datafile.h:56
virtual bool seek(int64 offset, int whence=SEEK_SET)
Definition: datafile.h:65
virtual bool err() const
Definition: datafile.h:51