[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Proposal: Virtualization of Filesystem Operations for Lua 5.2.
- From: Petite Abeille <petite.abeille@...>
- Date: Wed, 2 Nov 2011 23:29:40 +0100
On Nov 2, 2011, at 11:11 PM, Patrick Rapin wrote:
> This apart, I like very much that proposal. If such a file system
> visualization existed in 5.1, I could have used it to load modules
> from a ZIP file, instead of patching Lua source code.
> And I could have written a driver for our printer firmware pseudo file
> system, instead of removing the "io" library and writing a custom
FWIW, I like Georg Lehner proposal as well :)
That said, one could easily "virtualize/overload" the existing io module to suit its need.
local io = require( 'io' )
local ioopen = io.open
io.open = function( filename, mode, ... )
-- do stuff depending on mode
-- or default back to the standard implementation
return ioopen( filename, mode )