ResPaths.findRaw

This commit is contained in:
MihailRis
2024-04-19 14:22:14 +03:00
parent bedcc438f4
commit 0e69db13be
4 changed files with 29 additions and 26 deletions
+2 -17
View File
@@ -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) {