a71f592b8aeb75e981c62e9da631b5097c709198 — Gregor Best 29 days ago e62425b
Handle broken symlinks

This adds 'X' as a new flag for broken symlinks.
1 files changed, 11 insertions(+), 8 deletions(-)

M xplor.go
M xplor.go => xplor.go +11 -8
@@ 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 (


@@ 172,7 173,7 @@ func printContents(w io.Writer, dir string, depth int) error {
 		path := filepath.Join(dir, name)
 		if info.Mode()&os.ModeSymlink != 0 {
 			if info, err = os.Stat(path); err != nil {
-				return err
+				log.Println("can't read symlink:", err)
 			}
 		}
 		if err := printEntry(w, path, info, depth); err != nil {


@@ 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] {