CCombinedContainer.cpp 911 B

1234567891011121314151617181920212223242526272829303132
  1. #include "CCombinedContainer.h"
  2. #include "CAssetLoadException.h"
  3. using namespace WallpaperEngine::Assets;
  4. void CCombinedContainer::add (CContainer* container)
  5. {
  6. this->m_containers.emplace_back (container);
  7. }
  8. const void* CCombinedContainer::readFile (std::string filename, uint32_t* length) const
  9. {
  10. auto cur = this->m_containers.begin ();
  11. auto end = this->m_containers.end ();
  12. for (; cur != end; cur ++)
  13. {
  14. try
  15. {
  16. // try to read the file on the current container, if the file doesn't exists
  17. // an exception will be thrown
  18. return (*cur)->readFile (filename, length);
  19. }
  20. catch (CAssetLoadException& ex)
  21. {
  22. // not found in this container, next try
  23. }
  24. }
  25. // no container was able to load the file, abort!
  26. throw CAssetLoadException (filename, "Cannot find file in any of the containers");
  27. }