get the file descriptor from the lua file handle.
luarocks install io-fileno
get the file descriptor from the lua file handle.
Parameters
f:file
: lua file handle.
Returns
fd:integer
: the file descriptor.
e.g.
local fileno = require('io.fileno')
local f = assert(io.open('./test.txt', 'w'))
-- returns a file descriptor that greater than 0
print(fileno(f))
f:close()
-- returns -1
print(fileno(f))