hide certain directories in FileManager

The exclude pattern should be editable by users in the future.
pull/2/merge
chrox 11 years ago
parent f542ffbf57
commit 905b315c81

@ -22,9 +22,11 @@ function FileChooser:changeToPath(path)
local filename = self.path.."/"..f local filename = self.path.."/"..f
local filemode = lfs.attributes(filename, "mode") local filemode = lfs.attributes(filename, "mode")
if filemode == "directory" and f ~= "." and f~=".." then if filemode == "directory" and f ~= "." and f~=".." then
if self.dir_filter(filename) then
table.insert(dirs, f) table.insert(dirs, f)
end
elseif filemode == "file" then elseif filemode == "file" then
if self.filter(filename) then if self.file_filter(filename) then
table.insert(files, f) table.insert(files, f)
end end
end end

@ -78,6 +78,7 @@ function showReader(file, pass)
end end
function showHomePage(path) function showHomePage(path)
local exclude_dirs = {"%.sdr$"}
local FileManager = FileChooser:new{ local FileManager = FileChooser:new{
title = "FileManager", title = "FileManager",
path = path, path = path,
@ -85,7 +86,13 @@ function showHomePage(path)
height = Screen:getHeight(), height = Screen:getHeight(),
is_borderless = true, is_borderless = true,
has_close_button = false, has_close_button = false,
filter = function(filename) dir_filter = function(dirname)
for _, pattern in ipairs(exclude_dirs) do
if dirname:match(pattern) then return end
end
return true
end,
file_filter = function(filename)
if DocumentRegistry:getProvider(filename) then if DocumentRegistry:getProvider(filename) then
return true return true
end end

Loading…
Cancel
Save