Have FTP-LS and FTP-DIR returns list of directory lines rather than

printing the directory to (current-output-port).
This commit is contained in:
sperber 2003-01-16 10:21:59 +00:00
parent 101109e785
commit f0448cb34f
1 changed files with 17 additions and 8 deletions

View File

@ -245,10 +245,11 @@
(code-with-prefix "1"))
(receive (newsock newsockaddr)
(accept-connection sock)
(dump (socket:inport newsock))
(let ((lines (port->lines (socket:inport newsock))))
(close-socket newsock)
(close-socket sock)
(ftp-read-reply connection))))
(ftp-read-reply connection)
lines))))
;;: connection [ x string ] -> status
(define (ftp-dir connection . maybe-dir)
@ -258,10 +259,18 @@
(code-with-prefix "1"))
(receive (newsock newsockaddr)
(accept-connection sock)
(dump (socket:inport newsock))
(let ((lines (port->lines (socket:inport newsock))))
(close-socket newsock)
(close-socket sock)
(ftp-read-reply connection))))
(ftp-read-reply connection)
lines))))
(define (port->lines port)
(let loop ((reverse-lines '()))
(let ((line (rread-crlf-line port)))
(if (eof-object? line)
(reverse reverse-lines)
(loop (cons line reverse-lines))))))
;; maybe-local may be a filename to which the data should be written,