MCPcopy Create free account
hub / github.com/Tencent/UnLua / Lio_read

Function Lio_read

Plugins/UnLuaExtensions/LuaProtobuf/Source/src/pb.cpp:546–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546static int Lio_read(lua_State *L) {
547 const char *fname = luaL_optstring(L, 1, NULL);
548 FILE *fp = stdin;
549 int ret;
550 if (fname == NULL)
551 (void)setmode(fileno(stdin), O_BINARY);
552 else if ((fp = fopen(fname, "rb")) == NULL)
553 return luaL_fileresult(L, 0, fname);
554 lua_pushcfunction(L, io_read);
555 lua_pushlightuserdata(L, fp);
556 ret = lua_pcall(L, 1, 1, 0);
557 if (fp != stdin) fclose(fp);
558 else (void)setmode(fileno(stdin), O_TEXT);
559 if (ret != LUA_OK) { lua_pushnil(L); lua_insert(L, -2); return 2; }
560 return 1;
561}
562
563static int Lio_write(lua_State *L) {
564 int res;

Callers

nothing calls this directly

Calls 3

lua_pushlightuserdataFunction · 0.85
lua_pushnilFunction · 0.85
luaL_fileresultFunction · 0.70

Tested by

no test coverage detected