From 243b4cbc1fe392f4ea52f1f760f8a8f157e681a6 Mon Sep 17 00:00:00 2001 From: Ludovic Fauvet Date: Tue, 2 Feb 2016 16:39:34 +0100 Subject: [PATCH] RFC3659: add support for MLSD directory listing When supported by the remote server, one of the benefits is a precise last modification time compared to the default LIST command. --- ftp.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ftp.go b/ftp.go index a9d8be3..e4d7caf 100644 --- a/ftp.go +++ b/ftp.go @@ -534,7 +534,20 @@ func (c *ServerConn) NameList(path string) (entries []string, err error) { // List issues a LIST FTP command. func (c *ServerConn) List(path string) (entries []*Entry, err error) { - conn, err := c.cmdDataConnFrom(0, "LIST %s", path) + var conn net.Conn + + commands := []string{"MLSD", "LIST"} + if _, mlstSupported := c.features["MLST"]; !mlstSupported { + commands = commands[1:] + } + + for _, cmd := range commands { + conn, err = c.cmdDataConnFrom(0, "%s %s", cmd, path) + if err == nil { + break + } + } + if err != nil { return }