show symlink destination (#374)
Co-authored-by: wedens <kirill.wedens@gmail.com>
This commit is contained in:
1 parent
41e0bb32cd
commit
8933a3eafe
2 files changed
+12
-1
No files matched your search
@@ -28,6 +28,7 @@ const (
|
|||||||
type file struct {
|
type file struct {
|
||||||
os.FileInfo
|
os.FileInfo
|
||||||
linkState linkState
|
linkState linkState
|
||||||
|
linkTarget string
|
||||||
path string
|
path string
|
||||||
dirCount int
|
dirCount int
|
||||||
accessTime time.Time
|
accessTime time.Time
|
||||||
@@ -56,6 +57,7 @@ func readdir(path string) ([]*file, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var linkState linkState
|
var linkState linkState
|
||||||
|
var linkTarget string
|
||||||
|
|
||||||
if lstat.Mode()&os.ModeSymlink != 0 {
|
if lstat.Mode()&os.ModeSymlink != 0 {
|
||||||
stat, err := os.Stat(fpath)
|
stat, err := os.Stat(fpath)
|
||||||
@@ -65,6 +67,10 @@ func readdir(path string) ([]*file, error) {
|
|||||||
} else {
|
} else {
|
||||||
linkState = broken
|
linkState = broken
|
||||||
}
|
}
|
||||||
|
linkTarget, err = os.Readlink(fpath)
|
||||||
|
if err != nil {
|
||||||
|
return files, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := times.Get(lstat)
|
ts := times.Get(lstat)
|
||||||
@@ -85,6 +91,7 @@ func readdir(path string) ([]*file, error) {
|
|||||||
files = append(files, &file{
|
files = append(files, &file{
|
||||||
FileInfo: lstat,
|
FileInfo: lstat,
|
||||||
linkState: linkState,
|
linkState: linkState,
|
||||||
|
linkTarget: linkTarget,
|
||||||
path: fpath,
|
path: fpath,
|
||||||
dirCount: -1,
|
dirCount: -1,
|
||||||
accessTime: at,
|
accessTime: at,
|
||||||
|
|||||||
@@ -559,7 +559,11 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
return
|
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) {
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
|
|||||||
Reference in new issue
Block a user