A new FTP client implementation

A new implementation of the FTP client module has been available for downloading for a while. This module can be used to communicate with an FTP server, including Allegro FTPd (http://github.com/franzinc/aftpd/). It can be downloaded using sys:update-allegro. The relevant file is ftp.fasl.

The current version of the module is 2.1. This module was originally written sometime around 1996, appearing in Allegro CL 5.0.1 as an example. Sometime after 5.0.1 was released, it was also distributed in binary form, as code/ftp.fasl.. Shortly after the release of Allegro CL 6.2, version 2.0 was released with additional operators. (Also in 2.0, the package associated with the module was changed to net.ftp.client, although the previous exports in the acl-socket package were maintained for compatibility.) Version 2.1, which provides even more functionality was released earlier this year.

The module is described in ftp.htm. Individual operators and variables are for the moment described in that document rather than individual pages.

The Allegro FTP client module can do the following:

  • Copy files to and from remote hosts.
  • Append to remote files.
  • Make and delete remote directories.
  • Change the modes of remote files.
  • Retrieve the file modification time and size of remote files.
  • Walk remote file structures.

Here is a simple example. On a Windows machine, we connect with host ftp.franz.com and download the file pub/patches/6.2/README. (This file describes the patch system and how to manually download patches. Users typically do not see this file because patches are downloaded with sys:update-allegro. If you wish to look at the file after it is downloaded, use Wordpad since formating marks make it unreadable using Notepad.)

We use the macro net.ftp.client:with-open-ftp-connection, which (analogously to with-open-file) executes a body of code while an FTP connection is open, and then closes the connection; and the function net.ftp.client:ftp-stream-get, which downloads a file.

cg-user(2): (require :ftp); Fast loading C:\Program Files\acl62\code\ftp.002
;   Fast loading C:\Program Files\acl62\code\resource.fasl
;   Fast loading C:\Program Files\acl62\code\acldns.002
t
cg-user(3): (use-package :net.ftp.client)
t
cg-user(4): (probe-file "c:\\temp\\readme")
nil
cg-user(5): (with-open-ftp-connection (x "ftp.franz.com")
              (ftp-stream-get x "pub/patches/6.2/README"
                       "c:\\temp\\readme"))
t
cg-user(6): (probe-file "c:\\temp\\readme")
#p"c:\\temp\\readme"
cg-user(7): 
Copyright © 2023 Franz Inc., All Rights Reserved | Privacy Statement Twitter