Skip to content

Commit

Permalink
correct message for folders that lf has no permission for (gokcehan#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
JurisMajors authored and gokcehan committed Jul 20, 2019
1 parent cb36e87 commit 27861f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -97,6 +98,7 @@ func newDir(path string) *dir {
path: path,
files: files,
allFiles: files,
noPerm: os.IsPermission(err),
}
}

Expand Down
5 changes: 5 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27861f0

Please sign in to comment.