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:
commit
bb62d0c5e2
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user