lua-users home
lua-l archive

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


On Mon, Feb 22, 2010 at 5:52 PM, Jorge <xxopxe@gmail.com> wrote:
> I have a module that does loadfile() to load some stuff. This stuff is
> placed with the module obviously. Tough all relative paths are relative
> to the where the main program lies (the one one doing the require()). If
> i could get the library's path i could fix the relaitve paths, but seems
> i can't get that?
> (Oh, and the same problem occures if my library attempts to loadlib()
> using relative paths).
> Right now i'm just symlinking into the main program's directory, ugh.
>
> Any tip?
>
> Jorge

In most cases, placing the following in a .lua file outside of any
function should get the directory which the file is placed in:
local path = debug.getinfo(1, "S").source:match[[^@?(.*[\/])[^\/]-$]]