mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge branch 'master' of github.com:hwhw/kindlepdfviewer into djvu-highlight
Conflicts: blitbuffer.c unireader.lua
This commit is contained in:
28
reader.lua
28
reader.lua
@@ -34,22 +34,26 @@ longopts = {
|
||||
}
|
||||
|
||||
function openFile(filename)
|
||||
local file_type = string.lower(string.match(filename, ".+%.(.+)"))
|
||||
local file_type = string.lower(string.match(filename, ".+%.([^.]+)"))
|
||||
local reader = nil
|
||||
if file_type == "djvu" then
|
||||
if DJVUReader:open(filename) then
|
||||
page_num = DJVUReader.settings:readsetting("last_page") or 1
|
||||
DJVUReader:goto(tonumber(page_num))
|
||||
reader = DJVUReader
|
||||
elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then
|
||||
reader = PDFReader
|
||||
end
|
||||
if reader then
|
||||
local ok, err = reader:open(filename)
|
||||
if ok then
|
||||
reader:loadSettings(filename)
|
||||
page_num = reader.settings:readsetting("last_page") or 1
|
||||
reader:goto(tonumber(page_num))
|
||||
reader_settings:savesetting("lastfile", filename)
|
||||
return DJVUReader:inputloop()
|
||||
end
|
||||
elseif file_type == "pdf" then
|
||||
if PDFReader:open(filename,"") then -- TODO: query for password
|
||||
page_num = PDFReader.settings:readsetting("last_page") or 1
|
||||
PDFReader:goto(tonumber(page_num))
|
||||
reader_settings:savesetting("lastfile", filename)
|
||||
return PDFReader:inputloop()
|
||||
return reader:inputloop()
|
||||
else
|
||||
-- TODO: error handling
|
||||
end
|
||||
end
|
||||
return true -- on failed attempts, we signal to keep running
|
||||
end
|
||||
|
||||
function showusage()
|
||||
|
||||
Reference in New Issue
Block a user