A simple FTP client library.
Errors triggered by invalid or negative replies from the FTP server are signalled by raising a compund condition of the kinds exn and ftp. The error code of a ftp condition can be accessed with the code property.
This extension provides the ftp module.
- ftp:connect HOSTNAME USERNAME PASSWORD #!optional VERBOSE PORTprocedure
Connects to the server HOSTNAME using the FTP protocol and identifies this client with USERNAME with a given PASSWORD (all strings). If the optional argument VERBOSE is given and not #f, then a protocol of the communication with the server is written to the value of (current-error-port). PORT specifies the port-number and defaults to 21.
This procedure returns an object representing the FTP session.
- ftp:disconnect FTPprocedure
Closes the connection identified by the session object FTP.
- ftp:ftp? Xprocedure
Returns #t if X is an FTP session object, or #f otherwise.
- ftp:set-type! FTP TYPEprocedure
Sets the transmission to binary or character type. TYPE should one of the symbols binary, image or ascii.
- ftp:set-mode! FTP MODEprocedure
Selects active or passive mode. MODE should one of the symbols active or passive. Passive mode is the default.
- ftp:change-directory FTP DIRprocedure
Changes the current directory of the FTP session FTP to DIR.
- ftp:open-list FTP #!optional MASK LONGprocedure
Returns an input-port from which a directory list can be retrieved. The optional string MASK selects files to be listed (like *.scm). If the optional flag LONG is given and not #f, then the directory is requested in "long" format (if the server differentiates between short and long directory format). After the directory has been read, the port must be closed to allow further read/write operations in this FTP session.
- ftp:open-input-file FTP FILENAMEprocedure
Opens the file FILENAME for retrieval from the FTP server and returns an input-port from which the file can be read. After the file has been read, the port must be closed to allow further read/write operations in this FTP session.
- ftp:open-output-file FTP FILENAMEprocedure
Opens the file FILENAME the FTP server and returns an output-port to which the data to be stored should be written. After the file has been written, the port must be closed to allow further read/write operations in this FTP session.
- ftp:abort FTPprocedure
Aborts any transmission currently in progress for the given FTP session.
- ftp:delete-file FTP FILENAMEprocedure
Deletes the file FILENAME on the FTP server.
- ftp:rename-file FTP OLD NEWprocedure
Renames the file OLD on the FTP server to NEW.
- ftp:delete-directory FTP DIRNAMEprocedure
Deletes the directory DIRNAME on the FTP server.
- ftp:create-directory FTP DIRNAMEprocedure
Creates the directory DIRNAME on the FTP server.
; Connect to FTP server: (define f (ftp:connect "ftp.foo.com" "joe" "secret")) ; Retrieve directory listing: (let ([p (ftp:open-list f)]) (display (read-string #f p)) (close-input-port p) ) ; Download a file: (with-output-to-file "foo.txt" (lambda () (let ([p (ftp:open-input-file f "foo.txt")]) (display (read-string #f p)) (close-input-port p) ) ) ) ; Terminate connection: (ftp:disconnect f)
- 1.4 added regex dependency
- 1.3 Added matchable to list of dependencies in meta file
- 1.2 Ported to Chicken 4
- 1.1 Added support for passive mode.
- 1.0 Initial release
Copyright (c) 2003, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.