diff --git a/src/lib/include/jes/Runtime.h b/src/lib/include/jes/Runtime.h index f566884..c90b246 100644 --- a/src/lib/include/jes/Runtime.h +++ b/src/lib/include/jes/Runtime.h @@ -2,6 +2,7 @@ #define JES_RUNTIME_H #include "jes/Core.h" +#include "jes/Path.h" namespace jes { @@ -14,7 +15,7 @@ namespace jes SHADER, COUNT, }; - static StringRef locate(int type, const std::string & name); + static PathRef locate(int type, const std::string & name); }; } diff --git a/src/lib/src/Runtime.cc b/src/lib/src/Runtime.cc index 74bb3c0..7830459 100644 --- a/src/lib/src/Runtime.cc +++ b/src/lib/src/Runtime.cc @@ -7,8 +7,30 @@ namespace jes "shaders", }; - StringRef Runtime::locate(int type, const std::string & name) + PathRef Runtime::locate(int type, const std::string & name) { + auto path = Core::instance.get_bin_path()->dirname().join("runtime").join(runtime_directories[type]); + PathRef rv = NULL; + switch (type) + { + case Runtime::SHADER: + rv = new Path(path.join(name)); + case Runtime::FONT: + { + std::vector dirents = path.dir_entries(); + for (auto de : dirents) + { + auto test_path = path.join(de).join(name); + if (test_path.exists()) + { + rv = new Path(test_path); + break; + } + } + } + } + if (rv->exists()) + return rv; return NULL; } }