xoreos  0.0.5
sacfile.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/encoding.h"
27 
28 #include "sacfile.h"
29 
30 namespace Aurora {
31 
32 SACFile::SACFile(Common::SeekableReadStream *stream) : GFF3File(load(stream)), _stream(stream) {
33  if (getType() != MKTAG('S', 'A', 'V', ' '))
34  throw Common::Exception("Invalid GFF ID");
35 }
36 
38  return _levelFile;
39 }
40 
42  stream->skip(4); // Unknown value, probably a version header?
43  const uint32 nameLength = stream->readUint32LE(); // Length of the level identifier.
44 
45  _levelFile = Common::readStringFixed(*stream, Common::kEncodingASCII, nameLength); // The Level identifier string.
46 
47  stream->skip(4); // Unknown value, probably a checksum?
48 
49  return new Common::SeekableSubReadStream(stream, stream->pos(), stream->size());
50 }
51 
52 } // End of namespace Aurora
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
Definition: readstream.h:133
A class holding an UTF-8 string.
Definition: ustring.h:48
Implementing the reading stream interfaces for plain memory blocks.
Common::UString getLevelFile() const
Definition: sacfile.cpp:37
Common::UString _levelFile
Definition: sacfile.h:46
SACFile(Common::SeekableReadStream *stream)
Definition: sacfile.cpp:32
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
Definition: readstream.h:317
Utility functions for working with differing string encodings.
StackException Exception
Definition: error.h:59
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
virtual size_t pos() const =0
Obtains the current value of the stream position indicator of the stream.
uint32 getType() const
Return the GFF3&#39;s specific type.
Definition: gff3file.cpp:87
Plain, unextended ASCII (7bit clean).
Definition: encoding.h:40
uint32_t uint32
Definition: types.h:204
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
Definition: encoding.cpp:297
Handling GFF3 files with SAC header.
SeekableSubReadStream provides access to a SeekableReadStream restricted to the range [begin...
Definition: readstream.h:359
Interface for a seekable & readable data stream.
Definition: readstream.h:265
Common::SeekableReadStream * load(Common::SeekableReadStream *stream)
Definition: sacfile.cpp:41