From 40e60624e5b800f55c67474ab2d3e1fb72295753 Mon Sep 17 00:00:00 2001 From: haodreams Date: Tue, 5 Jan 2016 22:37:43 +0800 Subject: [PATCH] fix bug if file's name have more than one space, then name is error. eg:"aa a.txt" --> "aa a.txt" --- ftp.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ftp.go b/ftp.go index fd3648e..d32bd1a 100644 --- a/ftp.go +++ b/ftp.go @@ -390,7 +390,20 @@ func parseLsListLine(line string) (*Entry, error) { return nil, err } - e.Name = strings.Join(fields[8:], " ") + //e.Name = strings.Join(fields[8:], " ") //if "aa a.txt" then "aa a.txt" + idx := strings.Index(line, fields[7]) //not fields[8] + if idx > 0 { + e.Name = line[idx+len(fields[7]):] + e.Name = strings.TrimLeftFunc(e.Name, func(r rune) bool { + return r == '\t' || r == ' ' + }) + e.Name = strings.TrimRightFunc(e.Name, func(r rune) bool { + return r == '\r' || r == '\n' + }) + + } else { + e.Name = strings.Join(fields[8:], " ") + } return e, nil }