lua-users home
lua-l archive

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


2011/5/14 marbux <marbux@gmail.com>
>
> Hi, all,
>
> Before risking possible reinvention of the wheel, I ask whether anyone
> knows of an existing snippet to return a list of file paths for all
> files executed by a script and its chunk files using dofile? This is
> for an app that embeds standard Lua, no add-on libraries.
>

Not sure if I understand right what you are doing. But assuming I have
correctly understood that at some point you actually use 'dofile' to
run a script, and that this script will in turn use 'dofile' to run
other scripts, etc., why not just replace it by a function with the
same name that does the tracking you need, as in:

local old_dofile = dofile
dofile = function( ...)
  track_node( ...)
  return old_dofile( ...)
end


Since 'dofile' is a global identifier, any code that references it
should call yours instead.


--
Benoit.