[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: package location awareness?
- From: Asko Kauppi <asko.kauppi@...>
- Date: Thu, 3 Feb 2005 05:29:25 +0200
As a sidenote (this applies to the '-l' loaded libraries, not
-- Finding subscripts:
local LUA_PATH= rawget(_G,"package") and package.path or
assert( LUA_PATH, "Unable to get LUA_PATH!" )
for pat in string.gfind( LUA_PATH, "[^;]+" ) do
local try= string.gsub( pat, "?", "hamster" )
local fh= io.open(try,"r")
if fh then fh:close(); MY_PATH=
string.gsub(try,"hamster%.lua",""); break end
local hamsterlibs= assert( dofile( MY_PATH.."hamster_libs.lua" ) )
I think it's rather rediculous for all this code to be needed (in
_every_ Lua script that needs something from "where it came from") but
currently, there does not seem to be a better way?
For me, this code is more or less duplicated in:
..so you see the point? :)
3.2.2005 kello 00:07, David Burgess kirjoitti:
No, they define the actual search path.
I changed my loadlib.c to save the library handles in the package
table. You could do the same and maintain a list of where you
loaded things from. Beware that this all may change in work5.
I would prefer to have everything pretty much self-contained.
1) Add LUA_PATHSEP to luaconf.h
2) Push it into the package table in loadlib.c or lbaselib.c (i cant