[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to query current path from a library?
- From: Peter Cawley <lua@...>
- Date: Mon, 22 Feb 2010 17:57:06 +0000
On Mon, Feb 22, 2010 at 5:52 PM, Jorge <email@example.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?
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[[^@?(.*[\/])[^\/]-$]]