MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / f_seek

Function f_seek

extlibs/lua/src/liolib.c:682–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680
681
682static int f_seek (lua_State *L) {
683 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
684 static const char *const modenames[] = {"set", "cur", "end", NULL};
685 FILE *f = tofile(L);
686 int op = luaL_checkoption(L, 2, "cur", modenames);
687 lua_Integer p3 = luaL_optinteger(L, 3, 0);
688 l_seeknum offset = (l_seeknum)p3;
689 luaL_argcheck(L, (lua_Integer)offset == p3, 3,
690 "not an integer in proper range");
691 op = l_fseek(f, offset, mode[op]);
692 if (op)
693 return luaL_fileresult(L, 0, NULL); /* error */
694 else {
695 lua_pushinteger(L, (lua_Integer)l_ftell(f));
696 return 1;
697 }
698}
699
700
701static int f_setvbuf (lua_State *L) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected