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.
This commit is contained in:
Ludovic Fauvet 2016-02-02 16:39:34 +01:00
parent 7240d6ebcf
commit 243b4cbc1f

15
ftp.go
View File

@ -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
}