fill in Runtime::locate()

This commit is contained in:
Josh Holtrop 2014-06-22 16:02:40 -04:00
parent c001fca012
commit 6a51c5a880
2 changed files with 25 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#define JES_RUNTIME_H #define JES_RUNTIME_H
#include "jes/Core.h" #include "jes/Core.h"
#include "jes/Path.h"
namespace jes namespace jes
{ {
@ -14,7 +15,7 @@ namespace jes
SHADER, SHADER,
COUNT, COUNT,
}; };
static StringRef locate(int type, const std::string & name); static PathRef locate(int type, const std::string & name);
}; };
} }

View File

@ -7,8 +7,30 @@ namespace jes
"shaders", "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<std::string> 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; return NULL;
} }
} }