correct message for folders that lf has no permission for (#203)

This commit is contained in:
Juris Arturs Majors 2019-07-20 14:44:20 +02:00 committed by gokcehan
parent cb36e87b80
commit 27861f06e2
2 changed files with 7 additions and 0 deletions

2
nav.go
View File

@ -82,6 +82,7 @@ type dir struct {
files []*file // displayed files in directory including or excluding hidden ones files []*file // displayed files in directory including or excluding hidden ones
allFiles []*file // all files in directory including hidden ones (same array as files) allFiles []*file // all files in directory including hidden ones (same array as files)
sortType sortType // sort method and options from last sort sortType sortType // sort method and options from last sort
noPerm bool // whether lf has no permission to open the directory
} }
func newDir(path string) *dir { func newDir(path string) *dir {
@ -97,6 +98,7 @@ func newDir(path string) *dir {
path: path, path: path,
files: files, files: files,
allFiles: files, allFiles: files,
noPerm: os.IsPermission(err),
} }
} }

5
ui.go
View File

@ -251,6 +251,11 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b
return return
} }
if dir.noPerm {
win.print(2, 0, termbox.AttrReverse, termbox.ColorDefault, "permission denied")
return
}
if len(dir.files) == 0 { if len(dir.files) == 0 {
win.print(2, 0, termbox.AttrReverse, termbox.ColorDefault, "empty") win.print(2, 0, termbox.AttrReverse, termbox.ColorDefault, "empty")
return return