If a entry is link, split the entry.Name by '->', save the first part to entry.Name and the second part to entry.PointTo
This commit is contained in:
parent
80fcd9720b
commit
b0a00d8e31
8
ftp.go
8
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user