ResPaths.findRaw
This commit is contained in:
@@ -19,25 +19,10 @@ static fs::path resolve_path(lua_State* L, const std::string& path) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: move to ResPaths
|
||||
static int l_file_find(lua_State* L) {
|
||||
std::string path = lua_tostring(L, 1);
|
||||
|
||||
auto& packs = scripting::engine->getContentPacks();
|
||||
for (int i = packs.size()-1; i >= 0; i--) {
|
||||
auto& pack = packs[i];
|
||||
if (fs::exists(pack.folder / fs::path(path))) {
|
||||
lua_pushstring(L, (pack.id+":"+path).c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
auto resDir = scripting::engine->getResPaths()->getMainRoot();
|
||||
if (fs::exists(resDir / fs::path(path))) {
|
||||
lua_pushstring(L, ("core:"+path).c_str());
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "file not found %q", path.c_str());
|
||||
return 0;
|
||||
lua_pushstring(L, scripting::engine->getResPaths()->findRaw(path).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_file_resolve(lua_State* L) {
|
||||
|
||||
Reference in New Issue
Block a user