237 if #resources > 0 then |
237 if #resources > 0 then |
238 print_verbose("Packing resources...") |
238 print_verbose("Packing resources...") |
239 f:write("do local resources = {};\n"); |
239 f:write("do local resources = {};\n"); |
240 for _, resource in ipairs(resources) do |
240 for _, resource in ipairs(resources) do |
241 local name, path = resource.name, resource.path; |
241 local name, path = resource.name, resource.path; |
242 local res_file, err = io.open(base_path..path); |
242 local res_file, err = io.open(base_path..path, "rb"); |
243 if not res_file then |
243 if not res_file then |
244 print_err("Couldn't load resource: "..tostring(err)); |
244 print_err("Couldn't load resource: "..tostring(err)); |
245 os.exit(1); |
245 os.exit(1); |
246 end |
246 end |
247 local data = res_file:read("*a"); |
247 local data = res_file:read("*a"); |
248 local maxequals = 0; |
248 local maxequals = 0; |
249 data:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end); |
249 data:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end); |
250 |
250 |
251 f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "["); |
251 f:write(("resources[%q] = %q"):format(name, data)); |
|
252 --[[ f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "["); |
252 f:write(data); |
253 f:write(data); |
253 f:write("]", string.rep("=", maxequals+1), "];"); |
254 f:write("]", string.rep("=", maxequals+1), "];"); ]] |
254 end |
255 end |
255 if opts.virtual_io then |
256 if opts.virtual_io then |
256 local vio = require_resource("vio"); |
257 local vio = require_resource("vio"); |
257 if not vio then |
258 if not vio then |
258 print_err("Virtual IO requested but is not enabled in this build of squish"); |
259 print_err("Virtual IO requested but is not enabled in this build of squish"); |