compress paths like "test/pdf/../epub" into "test/epub" in FileChooser

This patch fixes Bug #107
This commit is contained in:
chrox
2013-07-13 15:24:10 +08:00
parent c8efeb3cc3
commit 6c4248251c

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