199 print_err("Virtual IO requested but is not enabled in this build of squish"); |
199 print_err("Virtual IO requested but is not enabled in this build of squish"); |
200 else |
200 else |
201 -- Insert vio library |
201 -- Insert vio library |
202 f:write(vio, "\n") |
202 f:write(vio, "\n") |
203 -- Override io.open to use vio if opening a resource |
203 -- Override io.open to use vio if opening a resource |
204 f:write[[local io_open = io.open; function io.open(fn, mode) |
204 f:write[[local io_open, io_lines = io.open, io.lines; function io.open(fn, mode) |
205 if not resources[fn] then |
205 if not resources[fn] then |
206 return io_open(fn, mode); |
206 return io_open(fn, mode); |
207 else |
207 else |
208 return vio.open(resources[fn]); |
208 return vio.open(resources[fn]); |
209 end end ]] |
209 end end |
|
210 function io.lines(fn) |
|
211 if not resources[fn] then |
|
212 return io_lines(fn); |
|
213 else |
|
214 return vio.open(resources[fn]):lines() |
|
215 end end ]] |
210 end |
216 end |
211 end |
217 end |
212 f:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]] |
218 f:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]] |
213 end |
219 end |
214 |
220 |