2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

Merge pull request #157 from chrox/path_compress

compress paths like "test/pdf/../epub" into "test/epub" in FileChooser
This commit is contained in:
{Qingping,Dave} Hou 2013-07-13 01:33:22 -07:00
commit bb62d0c5e2

View File

@ -13,7 +13,17 @@ function FileChooser:init()
self:changeToPath(self.path)
end
function FileChooser:compressPath(item_path)
-- compress paths like "test/pdf/../epub" into "test/epub"
local path = item_path
while path:match("/[^/]+[/][\\.][\\.]") do
path = path:gsub("/[^/]+[/][\\.][\\.]", "")
end
return path
end
function FileChooser:changeToPath(path)
path = self:compressPath(path)
local dirs = {}
local files = {}
self.path = path