lua-users home
lua-l archive

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


Alexander Gladysh wrote:
> > The underlying OS functions do not expose their lookup paths. You
> > can easily build this functionality yourself on top of ffi.load().
> 
> With a chain of pcall-s()... and with reinventing lookup logic (which
> is exposed in 5.2 only, AFAIR)...

You mean package.searchpath()? I might add that function, anyway.
However this wouldn't completely solve your problem, since you'd
have to supply the OS-specific path, too. Or you could defer to
the default lookup if package.searchpath() returns nil.

I mean ... for a single local path, this would do just fine:

  local mypath = "/where/ever/"
  local function myload(name)
    local ok, lib = pcall(ffi.load, mypath..name..".so")
    return ok and lib or ffi.load(name)
  end

--Mike