From b0a00d8e31da3aaf575c36d14a22d29023f96471 Mon Sep 17 00:00:00 2001 From: mengqi <5b5f7426@gmail.com> Date: Thu, 5 Feb 2015 11:09:57 +0800 Subject: [PATCH] If a entry is link, split the entry.Name by '->', save the first part to entry.Name and the second part to entry.PointTo --- ftp.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ftp.go b/ftp.go index 5fe19fe..0042425 100644 --- a/ftp.go +++ b/ftp.go @@ -32,6 +32,7 @@ type ServerConn struct { // Entry describes a file and is returned by List(). type Entry struct { Name string + PointTo string Type EntryType Size uint64 Time time.Time @@ -305,6 +306,13 @@ func parseListLine(line string) (*Entry, error) { e.Time = t e.Name = strings.Join(fields[8:], " ") + if e.Type == EntryTypeLink { + name := strings.SplitN(e.Name, " -> ", 2) + e.Name = name[0] + if len(name) > 1 { + e.PointTo = name[1] + } + } return e, nil }