52 throw Common::Exception(
"No zlib header, this doesn't look like an Aspyr OBB virtual filesystem");
61 e.
add(
"Failed reading OBB file");
73 for (
uint32 i = 0; i < resCount; i++) {
99 res.
index = resIndex++;
131 static const byte kZlibHeader[6] = { 0x00, 0x00, 0x00, 0x00, 0x78, 0x9C };
132 static const size_t kMaxReadBack = 0xFFFFFF;
139 WRITE_LE_UINT32(offsetData + 0, lastZlib + 4);
140 WRITE_LE_UINT32(offsetData + 4, 0);
148 obbZIndexStart.seek(0);
201 while (bytesLeft > 0) {
202 const size_t bytesChunk =
204 data.
get() + offset, bytesLeft, 4096);
206 offset += bytesChunk;
207 bytesLeft -= bytesChunk;
OBBFile(Common::SeekableReadStream *obb)
Take over this stream and read an OBB file out of it.
uint32 uncompressedSize
The resource's uncompressed size.
void add(const char *s,...) GCC_PRINTF(2
uint32 readUint32LE()
Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it...
#define TypeMan
Shortcut for accessing the file type manager.
const ResourceList & getResources() const
Return the list of resources.
A class holding an UTF-8 string.
PointerType release()
Returns the plain pointer value and releases ScopedPtr.
Common::ScopedPtr< Common::SeekableReadStream > _obb
Implementing the reading stream interfaces for plain memory blocks.
Utility functions to handle files used in BioWare's Aurora engine.
const IResource & getIResource(uint32 index) const
Common::UString name
The resource's name.
Utility templates and functions for working with strings and streams.
size_t decompressDeflateChunk(SeekableReadStream &input, int windowBits, byte *output, size_t outputSize, unsigned int frameSize)
Decompress (inflate) using zlib's DEFLATE algorithm, until a stream end marker was reached...
Exception that provides a stack of explanations.
ResourceList _resources
External list of resource names and types.
Basic exceptions to throw.
size_t searchBackwards(SeekableReadStream &haystack, const byte *needle, size_t needleSize, size_t maxReadBack)
Search the stream, backwards, for the last occurrence of a set of bytes.
Utility templates and functions.
uint16 readUint16BE()
Read an unsigned 16-bit word stored in big endian (MSB first) order from the stream and return it...
void load(Common::SeekableReadStream &obb)
std::list< Resource > ResourceList
uint32 getResourceSize(uint32 index) const
Return the size of a resource.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
uint32 compressedSize
The resource's compressed size.
Simple memory based 'stream', which implements the ReadStream interface for a plain memory block...
Utility functions for working with differing string encodings.
Internal resource information.
uint32 offset
The offset of the resource within the OBB.
A resource within the archive.
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
byte * decompressDeflateWithoutOutputSize(const byte *data, size_t inputSize, size_t &outputSize, int windowBits, unsigned int frameSize)
Decompress (inflate) using zlib's DEFLATE algorithm without knowing the output size.
Common::SeekableReadStream * getResource(uint32 index, bool tryNoCopy=false) const
Return a stream of the resource's contents.
Plain, unextended ASCII (7bit clean).
static const int kWindowBitsMax
PointerType get() const
Returns the plain pointer value.
FileType type
The resource's type.
void readResList(Common::SeekableReadStream &index)
Common::SeekableReadStream * getIndex(Common::SeekableReadStream &obb)
IResourceList _iResources
Internal list of resource offsets and sizes.
Handling Aspyr's OBB virtual filesystems.
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
SeekableSubReadStream provides access to a SeekableReadStream restricted to the range [begin...
Compress (deflate) and decompress (inflate) using zlib's DEFLATE algorithm.
Interface for a seekable & readable data stream.
uint32 index
The resource's local index within the archive.