[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Working with Lua 5.1 'require' for fake/virtual/non-standard files
- From: "E. Wing" <ewmailing@...>
- Date: Mon, 5 Jun 2006 13:52:58 -0700
I've been using 'require' as basically a #include (actually more like
#import) for Lua scripts. However, I've been using one of those zip
packaging systems like zzipllib or PhysFS so all my scripts are
contained within a single large zip file. This means I cannot use
standard ANSI C file methods to access these files. In Lua 5.0, I
simply cut-and-paste the function "luaB_require" function located in
lbaselib.c and made a few code substitutions to go through my own file
loaders (which ultimately use loadbuffer) instead of lua_loadfile. I
was fortunate that this function used all public APIs so I could
continue to use stock Lua and just make my scripts use my special
version of require (e.g. mystuff.require).
I've started migrating to Lua 5.1, but the old 'luaB_require' code I
copied no longer compiles. I noticed that 'require' code base is
considerably more complicated than before. I've been sniffing around
loadlib.c, but I'm getting the impression that it uses more than just
public APIs. I would like to continue using stock Lua.
So I was wondering if somebody can explain to me how I can work with
the new 5.1 system to load my zipped/archived scripts, in a way that
doesn't require me to modify stock Lua or modify all my scripts. (I
prefer my changes to be in the C part of my program).
Thanks,
Eric