Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show symlink destination #374

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
type file struct {
os.FileInfo
linkState linkState
linkTarget string
path string
dirCount int
accessTime time.Time
Expand Down Expand Up @@ -56,6 +57,7 @@ func readdir(path string) ([]*file, error) {
}

var linkState linkState
var linkTarget string

if lstat.Mode()&os.ModeSymlink != 0 {
stat, err := os.Stat(fpath)
Expand All @@ -65,6 +67,10 @@ func readdir(path string) ([]*file, error) {
} else {
linkState = broken
}
linkTarget, err = os.Readlink(fpath)
if err != nil {
return files, err
}
}

ts := times.Get(lstat)
Expand All @@ -85,6 +91,7 @@ func readdir(path string) ([]*file, error) {
files = append(files, &file{
FileInfo: lstat,
linkState: linkState,
linkTarget: linkTarget,
path: fpath,
dirCount: -1,
accessTime: at,
Expand Down
6 changes: 5 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,11 @@ func (ui *ui) loadFileInfo(nav *nav) {
return
}

ui.echof("%v %4s %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt))
var linkTarget string
if curr.linkTarget != "" {
linkTarget = " -> " + curr.linkTarget
}
ui.echof("%v %4s %v%s", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt), linkTarget)
}

func (ui *ui) drawPromptLine(nav *nav) {
Expand Down