Browse Source

Merge pull request #9 from WesTower/master

Added NLST-equivalent command
Julien Laffaye 12 years ago
parent
commit
460814bcb1
1 changed files with 20 additions and 0 deletions
  1. 20 0
      ftp.go

+ 20 - 0
ftp.go

@@ -302,6 +302,26 @@ func parseListLine(line string) (*Entry, error) {
 	return e, nil
 	return e, nil
 }
 }
 
 
+// NameList issues an NLST FTP command.
+func (c *ServerConn) NameList(path string) (entries []string, err error) {
+	conn, err := c.cmdDataConn("NLST %s", path)
+	if err != nil {
+		return
+	}
+
+	r := &response{conn, c}
+	defer r.Close()
+
+	scanner := bufio.NewScanner(r)
+	for scanner.Scan() {
+		entries = append(entries, scanner.Text())
+	}
+	if err = scanner.Err(); err != nil {
+		return entries, err
+	}
+	return
+}
+
 // List issues a LIST FTP command.
 // List issues a LIST FTP command.
 func (c *ServerConn) List(path string) (entries []*Entry, err error) {
 func (c *ServerConn) List(path string) (entries []*Entry, err error) {
 	conn, err := c.cmdDataConn("LIST %s", path)
 	conn, err := c.cmdDataConn("LIST %s", path)