squish.lua

changeset 19
f72a0f535301
parent 16
aaf1b38007d8
child 20
1766b5a287e1
--- a/squish.lua	Sun Jul 26 00:51:10 2009 +0100
+++ b/squish.lua	Sun Jul 26 00:56:13 2009 +0100
@@ -193,6 +193,22 @@
 		f:write(data);
 		f:write("]", string.rep("=", maxequals+1), "];");
 	end
+	if opts.enable_virtual_io then
+		local vio = require_resource("vio");
+		if not vio then
+			print_err("Virtual IO requested but is not enabled in this build of squish");
+		else
+			-- Insert vio library
+			f:write(vio, "\n")
+			-- Override io.open to use vio if opening a resource
+			f:write[[local io_open = io.open; function io.open(fn, mode)
+					if not resources[fn] then
+						return io_open(fn, mode);
+					else
+						return vio.open(resources[fn]);
+				end end ]]
+		end
+	end
 	f:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]]
 end
 

mercurial