Common::SeekableReadStream *ArchiveMan::open(const Common::String &filename) { if (_fallBack && SearchMan.hasFile(filename)) { return SearchMan.createReadStreamForMember(filename); } return createReadStreamForMember(filename); }
Common::SeekableReadStream *XARCArchive::createReadStreamForMember(const Common::String &name) const { for (Common::ArchiveMemberList::const_iterator it = _members.begin(); it != _members.end(); ++it) { if ((*it)->getName() == name) { // Found it return createReadStreamForMember((const XARCMember *)it->get()); } } // Not found return 0; }
// Get a stream to file in the archive // - same as createReadStreamForMember except it checks if the file exists and will assert / output a debug message if not Common::SeekableReadStream *ResourceManager::getFileStream(const Common::String &name) const { // Check if the file exits in the archive if (!hasFile(name)) { debugC(2, kLastExpressDebugResource, "Error opening file: %s", name.c_str()); return NULL; } debugC(2, kLastExpressDebugResource, "Opening file: %s", name.c_str()); return createReadStreamForMember(name); }
Font *ResourceManager::loadFont() const { // Open the resource Common::SeekableReadStream *stream = createReadStreamForMember("font.dat"); if (!stream) return NULL; // Create the new background Font *f = new Font(); if (!f->load(stream)) { delete f; // stream should be freed by the Font instance return NULL; } return f; }
Cursor *ResourceManager::loadCursor() const { // Open the resource Common::SeekableReadStream *stream = createReadStreamForMember("cursors.tbm"); if (!stream) return NULL; // Create the new background Cursor *c = new Cursor(); if (!c->load(stream)) { delete c; // stream should be freed by the Cursor instance return NULL; } return c; }
Background *ResourceManager::loadBackground(const Common::String &name) const { // Open the resource Common::SeekableReadStream *stream = createReadStreamForMember(name + ".bg"); if (!stream) return NULL; // Create the new background & load the data Background *bg = new Background(); if (!bg->load(stream)) { delete bg; // stream should be freed by the Background instance return NULL; } return bg; }