MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / f_seek

Function f_seek

deps/lua/src/liolib.c:442–455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

440
441
442static int f_seek (lua_State *L) {
443 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
444 static const char *const modenames[] = {"set", "cur", "end", NULL};
445 FILE *f = tofile(L);
446 int op = luaL_checkoption(L, 2, "cur", modenames);
447 long offset = luaL_optlong(L, 3, 0);
448 op = fseek(f, offset, mode[op]);
449 if (op)
450 return pushresult(L, 0, NULL); /* error */
451 else {
452 lua_pushinteger(L, ftell(f));
453 return 1;
454 }
455}
456
457
458static int f_setvbuf (lua_State *L) {

Callers

nothing calls this directly

Calls 4

tofileFunction · 0.85
luaL_checkoptionFunction · 0.85
pushresultFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected