Changeset 6417 for code/trunk/src/libraries/core/Resource.cc
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/Resource.cc
r5781 r6417 28 28 29 29 #include "Resource.h" 30 31 #include <OgreException.h> 30 32 #include <OgreResourceGroupManager.h> 31 33 … … 34 36 std::string Resource::DEFAULT_GROUP(Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 35 37 36 DataStreamPtr Resource::open(const std::string& name , const std::string& group, bool bSearchGroupsIfNotFound)38 DataStreamPtr Resource::open(const std::string& name) 37 39 { 38 return Ogre::ResourceGroupManager::getSingleton().openResource(name, group, bSearchGroupsIfNotFound); 40 return Ogre::ResourceGroupManager::getSingleton().openResource(name, 41 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true); 39 42 } 40 43 41 DataStreamListPtr Resource::openMulti(const std::string& pattern , const std::string& group)44 DataStreamListPtr Resource::openMulti(const std::string& pattern) 42 45 { 43 return Ogre::ResourceGroupManager::getSingleton().openResources(pattern, group); 46 DataStreamListPtr resources(new Ogre::DataStreamList()); 47 const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 48 for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it) 49 { 50 DataStreamListPtr temp = Ogre::ResourceGroupManager::getSingleton().openResources(pattern, *it); 51 resources->insert(resources->end(), temp->begin(), temp->end()); 52 } 53 return resources; 44 54 } 45 55 46 bool Resource::exists(const std::string& name , const std::string& group)56 bool Resource::exists(const std::string& name) 47 57 { 48 return Ogre::ResourceGroupManager::getSingleton().resourceExists(group, name); 58 try 59 { 60 Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name); 61 return true; 62 } 63 catch (const Ogre::Exception&) 64 { 65 return false; 66 } 49 67 } 50 68 51 shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name , const std::string& group)69 shared_ptr<ResourceInfo> Resource::getInfo(const std::string& name) 52 70 { 71 std::string group; 72 try 73 { 74 group = Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(name); 75 } 76 catch (const Ogre::Exception&) 77 { 78 return shared_ptr<ResourceInfo>(); 79 } 53 80 Ogre::FileInfoListPtr infos = Ogre::ResourceGroupManager::getSingleton().findResourceFileInfo(group, name); 54 81 for (std::vector<Ogre::FileInfo>::const_iterator it = infos->begin(); it != infos->end(); ++it) … … 67 94 return shared_ptr<ResourceInfo>(); 68 95 } 96 97 StringVectorPtr Resource::findResourceNames(const std::string& pattern) 98 { 99 StringVectorPtr resourceNames(new Ogre::StringVector()); 100 const Ogre::StringVector& groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups(); 101 for (Ogre::StringVector::const_iterator it = groups.begin(); it != groups.end(); ++it) 102 { 103 StringVectorPtr temp = Ogre::ResourceGroupManager::getSingleton().findResourceNames(*it, pattern); 104 resourceNames->insert(resourceNames->end(), temp->begin(), temp->end()); 105 } 106 return resourceNames; 107 } 69 108 }
Note: See TracChangeset
for help on using the changeset viewer.