lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I would look at the source for the file lib and see what it expects. I am guessing a userdata with metatable. If you can make the same sort of object, it should Just Work.

Sent from my new BlackBerry Z10

From: Finn Wilcox
Sent: Thursday, February 21, 2013 8:30 PM
To: Lua mailing list
Reply To: Lua mailing list
Subject: pass a FILE* from C to Lua

I have a FILE* which I would like to pass from a C function to a Lua
function, such that the Lua code can treat it as an io.* file (i.e. call
methods on it like file:read(), file:seek(), file:close() etc.)

Is there any way to do this?

Unfortunately opening the file from within Lua is not possible in this
case; A 3rd-party library has already opened the file (and the API
offers no way to obtain the path.)

- Finn