FileInfoListPtr findResourceFileInfo (const String& _groupName, const String& _pattern, bool _recursive, bool _dirs) { OGRE_LOCK_AUTO_MUTEX // MEMCATEGORY_GENERAL is the only category supported for SharedPtr FileInfoListPtr vec(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); // Try to find in resource index first ResourceGroup* grp = getResourceGroup(_groupName); if (!grp) { GOTHOGRE_EXCEPT( "Cannot locate a resource group called '" << _groupName << "'"); } OGRE_LOCK_MUTEX(grp->OGRE_AUTO_MUTEX_NAME) // lock group mutex // Iterate over the archives LocationList::iterator i, iend; iend = grp->locationList.end(); for (i = grp->locationList.begin(); i != iend; ++i) { FileInfoListPtr lst = (*i)->archive->findFileInfo(_pattern, _recursive, _dirs); vec->insert(vec->end(), lst->begin(), lst->end()); } return vec; }
Archive *Find(String &filename) { ResourceGroup* grp = getResourceGroup("General"); if (!grp) OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot locate a resource group called 'General'", "ResourceGroupManager::openResource"); OGRE_LOCK_MUTEX(grp->OGRE_AUTO_MUTEX_NAME) // lock group mutex ResourceLocationIndex::iterator rit = grp->resourceIndexCaseSensitive.find(filename); if (rit != grp->resourceIndexCaseSensitive.end()) { // Found in the index Archive *fileArchive = rit->second; filename = fileArchive->getName() + "/" + filename; return fileArchive; } return NULL; }
bool ResourceManager::findResource(ResourceLoadOptions& options) { Path& path = options.name; for(auto it = resourceLoaders.begin(); it != resourceLoaders.end(); it++) { auto ext = PathGetFileExtension(options.name); auto loader = it->value.get(); if( loader->getResourceGroup() != options.group ) continue; Path newPath = StringFormat("%s.%s", path.c_str(), ext.c_str()); if (archive->existsFile(newPath)) { path = PathNormalize(newPath); return true; } } return false; }