lua-users home
lua-l archive

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


David J. Slate wrote:
> userdata	userdata	posix library for Lua 5.1 / 5.1.9
> /usr/local/bin/luajit: bad argument #1 to '?' (FILE* expected, got userdata)

It looks like luaposix copies the internal metatable for files and
attaches it to their own userdata object. This doesn't work with
LuaJIT. luaposix shouldn't access internals of the VM in this way.

But with LuaJIT there's no need to use luaposix. You can directly
access all POSIX C library functions with the FFI library.
Example:

  local ffi = require("ffi")
  ffi.cdef[[
  int mkdir(const char *pathname, unsigned int mode);
  int rmdir(const char *pathname);
  ]]
  ffi.C.mkdir("/tmp/testdir", 0x1ff)
  ffi.C.rmdir("/tmp/testdir")

--Mike