fill in Runtime::locate()
This commit is contained in:
parent
c001fca012
commit
6a51c5a880
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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<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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user