| 440 | |
| 441 | |
| 442 | static 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 | |
| 458 | static int f_setvbuf (lua_State *L) { |
nothing calls this directly
no test coverage detected