From 59476e44b9d72349fb094a665759729bef1c95b2 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 11 May 2010 15:38:21 +0000 Subject: Add support for getting a resource from the resource fork by name. svn-id: r49004 --- common/macresman.cpp | 14 ++++++++++++++ common/macresman.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/common/macresman.cpp b/common/macresman.cpp index f36f8b2fe3..fd17944fa9 100644 --- a/common/macresman.cpp +++ b/common/macresman.cpp @@ -381,6 +381,20 @@ Common::SeekableReadStream *MacResManager::getResource(uint32 typeID, uint16 res return _stream->readStream(len); } +Common::SeekableReadStream *MacResManager::getResource(Common::String filename) { + for (uint32 i = 0; i < _resMap.numTypes; i++) { + for (uint32 j = 0; j < _resTypes[i].items; j++) { + if (_resLists[i][j].nameOffset != -1 && filename.equalsIgnoreCase(_resLists[i][j].name)) { + _stream->seek(_dataOffset + _resLists[i][j].dataOffset); + uint32 len = _stream->readUint32BE(); + return _stream->readStream(len); + } + } + } + + return 0; +} + void MacResManager::readMap() { _stream->seek(_mapOffset + 22); diff --git a/common/macresman.h b/common/macresman.h index 4afd2eebab..5cd39cae26 100644 --- a/common/macresman.h +++ b/common/macresman.h @@ -61,6 +61,13 @@ public: */ Common::SeekableReadStream *getResource(uint32 typeID, uint16 resID); + /** + * Read resource from the Mac Binary file + * @param filename filename of the resource + * @return Pointer to a SeekableReadStream with loaded resource + */ + Common::SeekableReadStream *getResource(Common::String filename); + Common::SeekableReadStream *getDataFork(); Common::String getResName(uint32 typeID, uint16 resID); uint32 getResForkSize(); -- cgit v1.2.3