const maivi = @import("../root.zig"); const Connection = maivi.handler.Connection; const helpers = maivi.helpers; const lua = @import("root.zig"); const Lua = lua.Lua; pub fn lua_read(l: *Lua) !i32 { l.argCheck(l.isString(1), 1, "string"); const pathz = try l.toString(-1); const path = try maivi.allocator.dupe(u8, pathz); defer maivi.allocator.free(path); const conn = blk: { _ = l.getGlobal("ctx"); const ltype_ptr = l.getField(-1, "ptr"); defer l.pop(1); if (ltype_ptr != .light_userdata) return error.InvalidPtr; break :blk try l.toUserdata(Connection, -1); }; try maivi.lua.read_data(l, conn.io, path); return 1; }