Fixes for handling binary resources

Sat, 10 Oct 2009 17:37:56 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 10 Oct 2009 17:37:56 +0100
changeset 53
bd189ae0de00
parent 52
81265a8c6745
child 54
90bf9ea1aaf0

Fixes for handling binary resources

squish.lua file | annotate | diff | comparison | revisions
--- a/squish.lua	Mon Jul 27 13:21:25 2009 +0100
+++ b/squish.lua	Sat Oct 10 17:37:56 2009 +0100
@@ -239,7 +239,7 @@
 	f:write("do local resources = {};\n");
 	for _, resource in ipairs(resources) do
 		local name, path = resource.name, resource.path;
-		local res_file, err = io.open(base_path..path);
+		local res_file, err = io.open(base_path..path, "rb");
 		if not res_file then
 			print_err("Couldn't load resource: "..tostring(err));
 			os.exit(1);
@@ -248,9 +248,10 @@
 		local maxequals = 0;
 		data:gsub("(=+)", function (equals_string) maxequals = math.max(maxequals, #equals_string); end);
 		
-		f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "[");
+		f:write(("resources[%q] = %q"):format(name, data));
+--[[		f:write(("resources[%q] = ["):format(name), string.rep("=", maxequals+1), "[");
 		f:write(data);
-		f:write("]", string.rep("=", maxequals+1), "];");
+		f:write("]", string.rep("=", maxequals+1), "];"); ]]
 	end
 	if opts.virtual_io then
 		local vio = require_resource("vio");

mercurial