248e92cb755971db9f3197ae23bd294c168bc236 — Martin Kühl 29 days ago e62425b + 94ff91c master
Merge pull request #2 from farhaven/master

Handle broken symlinks
1 files changed, 13 insertions(+), 10 deletions(-)

M xplor.go
M xplor.go => xplor.go +13 -10
@@ 23,12 23,13 @@ import (
 )
 
 const (
-	this     = "xplor"
-	tag      = "Get All Up Cd Win Xplor "
-	tab      = "\t"
-	flagFile = " "
-	flagLess = "▸"
-	flagMore = "▾"
+	this       = "xplor"
+	tag        = "Get All Up Cd Win Xplor "
+	tab        = "\t"
+	flagFile   = " "
+	flagBroken = "X"
+	flagLess   = "▸"
+	flagMore   = "▾"
 )
 
 var (


@@ 171,9 172,9 @@ func printContents(w io.Writer, dir string, depth int) error {
 		name := info.Name()
 		path := filepath.Join(dir, name)
 		if info.Mode()&os.ModeSymlink != 0 {
-			if info, err = os.Stat(path); err != nil {
-				return err
-			}
+			// The error from os.Stat is ignored because logging it just spams the +Errors window
+			// on each repaint.
+			info, _ = os.Stat(path)
 		}
 		if err := printEntry(w, path, info, depth); err != nil {
 			return err


@@ 188,7 189,9 @@ func printEntry(w io.Writer, path string, info os.FileInfo, depth int) error {
 		return nil
 	}
 	flag := flagFile
-	if info.IsDir() {
+	if info == nil {
+		flag = flagBroken
+	} else if info.IsDir() {
 		name += "/"
 		flag = flagLess
 		if open[path] {