lua-users home
lua-l archive

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



On Wed, May 18, 2005 at 12:17:26PM +0100, Terisquas Brothers wrote:
> I'm trying to embed lua in a project where I can only
> have a single 
> file resource, containing a custom compressed virtual
> file system.
> I'd like to get require, do_file, ... functions
> working on my file system,
> so that each time i.e. a require is called I can get
> it uncompressed
> and loaded using my FS (otherwise I'd have to expand
> my files into 
> bigger files, which I'd prefer not)

sounds like a very nice application for a stdio replacement!
Linking a buffer to the uncompressor should be no problem.

> is there any standar/elegant way to do so or it's just
not, hmm, yet :)

> a matter of
> searching through the lua source and changing the
> opens or fopens to
it's fopens and there are not much of them.

> my custom open function, and so on?
if you can wait another 2-3 weeks,
we should have a reasonably working version.
(as some might have guessed, float printing is the problem,
but you probably use an integer based build?).

> Can be done from lua (for portability's 
> sake) instead of modifying lua sources?
at least not all at once, and obviously not for main.
lauxlib's luaL_loadfile,
used by loadfile, dofile, require and for the main script,
has a fopen with no means to hook in.
The former, however, could be redefined to fetch scripts
from wherever you like.