From 381b34cc04832fa7d7164b733088e8de47b20ec2 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Mon, 30 Apr 2012 16:58:05 +0800 Subject: [PATCH] detect file type in zip file, patched by NuPogodi@mobileread --- crereader.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crereader.lua b/crereader.lua index fa654b5e4..36956fcaf 100644 --- a/crereader.lua +++ b/crereader.lua @@ -30,10 +30,20 @@ end function CREReader:open(filename) local ok local file_type = string.lower(string.match(filename, ".+%.([^.]+)")) + -- these two format use the same css file if file_type == "html" then file_type = "htm" end + + -- detect file type for documents inside zip file + if file_type == "zip" then + -- store filename without zip-extention to fn + local fn = string.lower(string.sub(filename,0,-4)) + -- if no double extention then default file_type + file_type = string.lower(string.match(fn, ".+%.([^.]+)") or "fb2") + end + local style_sheet = "./data/"..file_type..".css" ok, self.doc = pcall(cre.openDocument, filename, style_sheet, G_width, G_height)