| 12351 | |
| 12352 | |
| 12353 | static int f_seek (lua_State *L) { |
| 12354 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; |
| 12355 | static const char *const modenames[] = {"set", "cur", "end", NULL}; |
| 12356 | FILE *f = tofile(L); |
| 12357 | int op = luaL_checkoption(L, 2, "cur", modenames); |
| 12358 | long offset = luaL_optlong(L, 3, 0); |
| 12359 | op = fseek(f, offset, mode[op]); |
| 12360 | if (op) |
| 12361 | return pushresult(L, 0, NULL); /* error */ |
| 12362 | else { |
| 12363 | lua_pushinteger(L, ftell(f)); |
| 12364 | return 1; |
| 12365 | } |
| 12366 | } |
| 12367 | |
| 12368 | |
| 12369 | static int f_setvbuf (lua_State *L) { |
nothing calls this directly
no test coverage detected