lua-users home
lua-l archive

A couple of questions

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


Hello Lua,
I could use a few pointers concerning the following:
1) How to obtain the name of a pre-compiled running script?
My first thought was debug.getinfo(1,'S').source, but it returns nil.
2) How can I make a script auto-load itself (when it notices
differences between itself and the one on disk, for example)? I
was thinking of doing something like this:
local modtime=lfs.attributes(fname,'modification')
local fname=debug.getinfo(1,'S').source
if (lfs.attributes(fname,'modification')~=modtime) then
 return dofile(fname)
end
But I doubt this solution is stack friendly. This check would be part
of an almost infinite loop that would look like this:
repeat
 BeUseful()
 Sleep()
 Update() -- this would be the previous code
until (noloop)
Any idea will be appreciated.
-- 
Theodor-Iulian Ciobanu
jr Virus Researcher
e-mail: tciobanu@bitdefender.com
-----------------------------------------
Secure your every bit
-----------------------------------------

AltStyle によって変換されたページ (->オリジナル) /