mirror of https://github.com/mpv-player/mpv
lua: do not use Lua filesystem functions for loading scripts
Bill Gates did not only create COVID, he's also responsible for the world's worst OS, where you have to literally jump through hoops of fire to open files with Unicode file names. Lua did not care to implement any jumping, so it's our turn to jump. Untested (on win32). Fixes: #7701
This commit is contained in:
parent
ad9f3bfe96
commit
a7d11b2fc0
|
@ -230,10 +230,13 @@ static void load_file(lua_State *L, const char *fname)
|
|||
{
|
||||
struct script_ctx *ctx = get_ctx(L);
|
||||
MP_DBG(ctx, "loading file %s\n", fname);
|
||||
int r = luaL_loadfile(L, fname);
|
||||
if (r)
|
||||
struct bstr s = stream_read_file(fname, ctx, ctx->mpctx->global, 100000000);
|
||||
if (!s.start)
|
||||
luaL_error(L, "Could not read file.\n");
|
||||
if (luaL_loadbuffer(L, s.start, s.len, fname))
|
||||
lua_error(L);
|
||||
lua_call(L, 0, 0);
|
||||
lua_call(L, 0, 1);
|
||||
talloc_free(s.start);
|
||||
}
|
||||
|
||||
static int load_builtin(lua_State *L)
|
||||
|
|
Loading…
Reference in New Issue