2
0

ResourceManager.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "anki/resource/ResourceManager.h"
  2. #include "anki/core/Logger.h"
  3. #include "anki/core/App.h"
  4. #include <cstring>
  5. namespace anki {
  6. //==============================================================================
  7. ResourceManager::ResourceManager()
  8. {
  9. if(getenv("ANKI_DATA_PATH"))
  10. {
  11. dataPath = getenv("ANKI_DATA_PATH");
  12. #if ANKI_POSIX
  13. dataPath += "/";
  14. #else
  15. dataPath = "\\";
  16. #endif
  17. ANKI_LOGI("Data path: %s", dataPath.c_str());
  18. }
  19. else
  20. {
  21. // Assume working directory
  22. #if ANKI_POSIX
  23. dataPath = "./";
  24. #else
  25. dataPath = ".\\";
  26. #endif
  27. }
  28. }
  29. //==============================================================================
  30. std::string ResourceManager::fixResourcePath(const char* filename) const
  31. {
  32. std::string newFname;
  33. // If the filename is in cache then dont append the data path
  34. const char* cachePath = AppSingleton::get().getCachePath().c_str();
  35. if(strstr(filename, cachePath) != nullptr)
  36. {
  37. newFname = filename;
  38. }
  39. else
  40. {
  41. newFname = ResourceManagerSingleton::get().getDataPath() + filename;
  42. }
  43. return newFname;
  44. }
  45. } // end namespace anki