50 if (magic != 0x00F1A5C0)
64 e.
add(
"Failed reading HERF file");
72 const size_t pos = herf.
pos();
74 for (
uint32 i = 0; i < resCount; i++) {
76 if (hash == dictHash) {
92 size_t pos = herf.
pos();
97 if (magic != 0x00F1A5C0)
102 for (
uint32 i = 0; i < hashCount; i++) {
114 std::map<uint32, Common::UString> dict;
118 ResourceList::iterator res =
_resources.begin();
119 IResourceList::iterator iRes =
_iResources.begin();
129 throw Common::Exception(
"HERFFile::readResList(): Resource goes beyond end of file");
131 std::map<uint32, Common::UString>::const_iterator name = dict.find(res->hash);
132 if (name != dict.end()) {
134 res->type =
TypeMan.getFileType(name->second);
uint32 _dictOffset
The offset of the dict file (if available).
static uint32 hashStringDJB2(const UString &string)
Common::HashAlgo getNameHashAlgo() const
Return with which algorithm the name is hashed.
Common::SeekableReadStream * getResource(uint32 index, bool tryNoCopy=false) const
Return a stream of the resource's contents.
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.
uint32 getResourceSize(uint32 index) const
Return the size of a resource.
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
Internal resource information.
Implementing the reading stream interfaces for plain memory blocks.
djb2 hash function by Daniel J. Bernstein.
Utility functions to handle files used in BioWare's Aurora engine.
Exception that provides a stack of explanations.
const IResource & getIResource(uint32 index) const
Basic exceptions to throw.
Utility templates and functions.
Common::ScopedPtr< Common::SeekableReadStream > _herf
void readDictionary(Common::SeekableReadStream &herf, std::map< uint32, Common::UString > &dict)
std::list< Resource > ResourceList
const ResourceList & getResources() const
Return the list of resources.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
BioWare's HERF (hashed ERF) file parsing.
Utility functions for working with differing string encodings.
HashAlgo
The algorithm used for hashing.
HERFFile(Common::SeekableReadStream *herf)
Take over this stream and read an HERF file out of it.
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.
void readResList(Common::SeekableReadStream &herf)
ResourceList _resources
External list of resource names and types.
void load(Common::SeekableReadStream &herf)
uint32 size
The resource's size.
Plain, unextended ASCII (7bit clean).
IResourceList _iResources
Internal list of resource offsets and sizes.
PointerType get() const
Returns the plain pointer value.
static UString getStem(const UString &p)
Return a file name's stem.
UString toLower() const
Return a lowercased copy of the string.
uint32 offset
The offset of the resource within the HERF.
UString readStringFixed(SeekableReadStream &stream, Encoding encoding, size_t length)
Read length bytes as a string with the given encoding out of a stream.
HERF file name -> hashes dictionary.
SeekableSubReadStream provides access to a SeekableReadStream restricted to the range [begin...
Interface for a seekable & readable data stream.
uint32 _dictSize
The size of the dict file (if available).
Utility class for manipulating file paths.
void searchDictionary(Common::SeekableReadStream &herf, uint32 resCount)