show symlink destination (#374)
Co-authored-by: wedens <kirill.wedens@gmail.com>
This commit is contained in:
parent
41e0bb32cd
commit
8933a3eafe
7
nav.go
7
nav.go
@ -28,6 +28,7 @@ const (
|
||||
type file struct {
|
||||
os.FileInfo
|
||||
linkState linkState
|
||||
linkTarget string
|
||||
path string
|
||||
dirCount int
|
||||
accessTime time.Time
|
||||
@ -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)
|
||||
@ -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)
|
||||
@ -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,
|
||||
|
6
ui.go
6
ui.go
@ -559,7 +559,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user