2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Allow renaming the whole file, including "extension".

This commit is contained in:
Tigran Aivazian 2012-08-29 10:33:42 +01:00
parent 42491bfefd
commit 7000f349c0

View File

@ -403,11 +403,9 @@ function FileChooser:addAllCommands()
local oldname = self:FullFileName()
if oldname then
local name_we = self.files[self.perpage*(self.page-1)+self.current - #self.dirs]
local ext = string.lower(string.match(oldname, ".+%.([^.]+)") or "")
name_we = string.sub(name_we,1,-2-string.len(ext))
local newname = InputBox:input(0, 0, "New filename:", name_we)
if newname then
newname = self.path.."/"..newname..'.'..ext
newname = self.path.."/"..newname
os.rename(oldname, newname)
os.rename(DocToHistory(oldname), DocToHistory(newname))
self:setPath(self.path)