Merge pull request #621 from chrox/master

take care of directory that we don't have permission
pull/626/head
HW 10 years ago
commit 4cc51ff040

@ -42,8 +42,11 @@ sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
```
A recent version of Android SDK/NDK is needed in order to build Koreader for Android
A recent version of Android SDK/NDK and `ant` are needed in order to build Koreader for Android
devices.
```
sudo apt-get install ant
```
You might also need SDL library packages if you want to compile and run
Koreader on PC. Fedora users can install `SDL` and `SDL-devel`.

@ -34,17 +34,20 @@ function FileChooser:genItemTableFromPath(path)
local dirs = {}
local files = {}
for f in lfs.dir(self.path) do
if self.show_hidden or not string.match(f, "^%.[^.]") then
local filename = self.path.."/"..f
local filemode = lfs.attributes(filename, "mode")
if filemode == "directory" and f ~= "." and f~=".." then
if self.dir_filter(filename) then
table.insert(dirs, f)
end
elseif filemode == "file" then
if self.file_filter(filename) then
table.insert(files, f)
-- lfs.dir directory without permission will give error
if pcall(lfs.dir, self.path) then
for f in lfs.dir(self.path) do
if self.show_hidden or not string.match(f, "^%.[^.]") then
local filename = self.path.."/"..f
local filemode = lfs.attributes(filename, "mode")
if filemode == "directory" and f ~= "." and f~=".." then
if self.dir_filter(filename) then
table.insert(dirs, f)
end
elseif filemode == "file" then
if self.file_filter(filename) then
table.insert(files, f)
end
end
end
end
@ -86,10 +89,12 @@ function FileChooser:toggleHiddenFiles()
end
function FileChooser:onMenuSelect(item)
if lfs.attributes(item.path, "mode") == "directory" then
self:changeToPath(item.path)
else
-- parent directory of dir without permission get nil mode
-- we need to change to parent path in this case
if lfs.attributes(item.path, "mode") == "file" then
self:onFileSelect(item.path)
else
self:changeToPath(item.path)
end
return true
end

Loading…
Cancel
Save