MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / f_seek

Function f_seek

3rd/lua-5.4.3/src/liolib.c:697–713  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695
696
697static int f_seek (lua_State *L) {
698 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
699 static const char *const modenames[] = {"set", "cur", "end", NULL};
700 FILE *f = tofile(L);
701 int op = luaL_checkoption(L, 2, "cur", modenames);
702 lua_Integer p3 = luaL_optinteger(L, 3, 0);
703 l_seeknum offset = (l_seeknum)p3;
704 luaL_argcheck(L, (lua_Integer)offset == p3, 3,
705 "not an integer in proper range");
706 op = l_fseek(f, offset, mode[op]);
707 if (l_unlikely(op))
708 return luaL_fileresult(L, 0, NULL); /* error */
709 else {
710 lua_pushinteger(L, (lua_Integer)l_ftell(f));
711 return 1;
712 }
713}
714
715
716static int f_setvbuf (lua_State *L) {

Callers

nothing calls this directly

Calls 5

tofileFunction · 0.85
luaL_checkoptionFunction · 0.85
luaL_optintegerFunction · 0.85
luaL_fileresultFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected