From 27861f06e2d3648bec44ec9476317282804f9cdd Mon Sep 17 00:00:00 2001 From: Juris Arturs Majors <32071671+JurisMajors@users.noreply.github.com> Date: Sat, 20 Jul 2019 14:44:20 +0200 Subject: [PATCH] correct message for folders that lf has no permission for (#203) --- nav.go | 2 ++ ui.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/nav.go b/nav.go index b4e07c8..9e0b58d 100644 --- a/nav.go +++ b/nav.go @@ -82,6 +82,7 @@ type dir struct { files []*file // displayed files in directory including or excluding hidden ones allFiles []*file // all files in directory including hidden ones (same array as files) 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 { @@ -97,6 +98,7 @@ func newDir(path string) *dir { path: path, files: files, allFiles: files, + noPerm: os.IsPermission(err), } } diff --git a/ui.go b/ui.go index 57439a3..f916ff8 100644 --- a/ui.go +++ b/ui.go @@ -251,6 +251,11 @@ func (win *win) printDir(dir *dir, selections map[string]int, saves map[string]b return } + if dir.noPerm { + win.print(2, 0, termbox.AttrReverse, termbox.ColorDefault, "permission denied") + return + } + if len(dir.files) == 0 { win.print(2, 0, termbox.AttrReverse, termbox.ColorDefault, "empty") return