191 |
191 |
192 f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "["); |
192 f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "["); |
193 f:write(data); |
193 f:write(data); |
194 f:write("]", string.rep("=", maxequals+1), "];"); |
194 f:write("]", string.rep("=", maxequals+1), "];"); |
195 end |
195 end |
|
196 if opts.enable_virtual_io then |
|
197 local vio = require_resource("vio"); |
|
198 if not vio then |
|
199 print_err("Virtual IO requested but is not enabled in this build of squish"); |
|
200 else |
|
201 -- Insert vio library |
|
202 f:write(vio, "\n") |
|
203 -- Override io.open to use vio if opening a resource |
|
204 f:write[[local io_open = io.open; function io.open(fn, mode) |
|
205 if not resources[fn] then |
|
206 return io_open(fn, mode); |
|
207 else |
|
208 return vio.open(resources[fn]); |
|
209 end end ]] |
|
210 end |
|
211 end |
196 f:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]] |
212 f:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]] |
197 end |
213 end |
198 |
214 |
199 print_debug("Finalising...") |
215 print_debug("Finalising...") |
200 for _, fn in pairs(main_files) do |
216 for _, fn in pairs(main_files) do |