void HERFFile::load() { Common::SeekableReadStream *herf = ResMan.getResource(TypeMan.setFileType(_fileName, kFileTypeNone), kFileTypeHERF); if (!herf) throw Common::Exception(Common::kOpenError); herf->skip(4); uint32 resCount = herf->readUint32LE(); _resources.resize(resCount); _iResources.resize(resCount); try { readResList(*herf); if (herf->err()) throw Common::Exception(Common::kReadError); } catch (Common::Exception &e) { delete herf; e.add("Failed reading HERF file"); throw e; } delete herf; }
void RIMFile::load(Common::SeekableReadStream &rim) { readHeader(rim); if (_id != kRIMID) throw Common::Exception("Not a RIM file (%s)", Common::debugTag(_id).c_str()); if (_version != kVersion1) throw Common::Exception("Unsupported RIM file version %s", Common::debugTag(_version).c_str()); rim.skip(4); // Reserved uint32 resCount = rim.readUint32LE(); // Number of resources in the RIM uint32 offResList = rim.readUint32LE(); // Offset to the resource list _resources.resize(resCount); _iResources.resize(resCount); try { // Read the resource list readResList(rim, offResList); } catch (Common::Exception &e) { e.add("Failed reading RIM file"); throw; } }
static int readTypeList( WResFileID handle, WResDirHead * currdir, uint_16 ver, void *fileinfo ) { WResTypeNode * newnode; WResTypeInfo newtype; int error; int typenum; int extrabytes; /* loop through the list of types */ for (error = FALSE, typenum = 0; typenum < currdir->NumTypes && !error; typenum++) { /* read a type record from disk */ if( ver < 3 ) { error = WResReadFixedTypeRecord2( &newtype, handle ); } else { error = WResReadFixedTypeRecord( &newtype, handle ); } if( !error ) { /* allocate a new node */ extrabytes = WResIDExtraBytes( &(newtype.TypeName) ); newnode = WRESALLOC( sizeof(WResTypeNode) + extrabytes ); if( newnode == NULL ) { error = TRUE; WRES_ERROR( WRS_MALLOC_FAILED ); } } if( !error ) { /* initialize the linked list of resources */ newnode->Head = NULL; newnode->Tail = NULL; /* copy the new type info into the new node */ memcpy( &(newnode->Info), &newtype, sizeof(WResTypeInfo) ); /* read the extra bytes (if any) */ if( extrabytes > 0 ) { error = WResReadExtraWResID( &(newnode->Info.TypeName), handle ); } } if( !error ) { /* add the type node to the linked list */ ResAddLLItemAtEnd( (void **)&(currdir->Head), (void **)&(currdir->Tail), newnode ); /* read in the list of resources of this type */ error = readResList( handle, newnode, ver, fileinfo ); } } return( error ); } /* readTypeList */
void KEYFile::load(Common::SeekableReadStream &key) { readHeader(key); if (_id != kKEYID) throw Common::Exception("Not a KEY file (%s)", Common::debugTag(_id).c_str()); if ((_version != kVersion1) && (_version != kVersion11)) throw Common::Exception("Unsupported KEY file version %s", Common::debugTag(_version).c_str()); uint32 bifCount = key.readUint32LE(); uint32 resCount = key.readUint32LE(); _bifs.reserve(bifCount); _resources.reserve(resCount); // Version 1.1 has some NULL bytes here if (_version == kVersion11) key.skip(4); uint32 offFileTable = key.readUint32LE(); uint32 offResTable = key.readUint32LE(); key.skip( 8); // Build year and day key.skip(32); // Reserved try { _bifs.resize(bifCount); readBIFList(key, offFileTable); _resources.resize(resCount); readResList(key, offResTable); } catch (Common::Exception &e) { e.add("Failed reading KEY file"); throw; } }