- Inherits from:
- Object
- Declared in:
- DFTPClient.h
Object
|
+---DFTPClient
Class Description
The DFTPClient class implements a number of methods for building a FTP (File
Transfer Protocol) client.
- Last modified:
- 05-Nov-2007 (DFTPClient.h)
Instance Variables
- private DSocket *_client
- the client socket
- private DText *_request
- the request for the server
- private DText *_response
- the response from the server
- private DText *_directory
- the directory info received from the server
- private id <DSocketAddressable> _server
- the address of the server
- private id <DSocketAddressable> _address
- the address received from the server
- private int _bytes
- the number of bytes received from the server
- private BOOL _connected
- is there a connection to the server ?
- private int _port
- the active port (or 0 for passive mode)
- private int _code
- the response code
- private int _bufferSize
- the buffer size during binary transfer (def. 8192)
- Constructors
- - (DFTPClient *) init
- Initialise the FTP Client
- Returns:
- the object
- Deconstructor
- - free
- Free the FTP client object
- Returns:
- the object
- Copy related methods
- - deepen
- Deepen the object (not implemented)
- Member methods
- - (DFTPClient *) active :(int) port
- Set the ftp client in active mode
- Parameters:
- port - the port to be used during transfer of data with the server
- Returns:
- the object
- - (int) bufferSize
- Get the buffer size during binary transfer
- Returns:
- the size
- - (DFTPClient *) bufferSize :(int) size
- Set the buffer size during binary transfer
- Parameters:
- size - the buffer size
- Returns:
- the object
- - (int) bytes
- Get the number of bytes received from the server (response 150)
- Returns:
- the number of bytes (or -1)
- - (const char *) directory
- Get the directory name from the last response with a directory name
- Returns:
- the directory name (or EOS)
- - (BOOL) isConnected
- Check if there is a connection to the server
- Returns:
- is there a connection ?
- - (BOOL) mode
- Return the mode of the ftp client
- Returns:
- the mode (DFPC_PASSIVE or DFPC_ACTIVE)
- - (DFTPClient *) passive
- Set the ftp client in passive mode
- Returns:
- the object
- - (int) responseCode
- Get the last response code
- Returns:
- the last response code (1xx-5xx, -1)
- - (DSocket *) socket
- Return the local socket
- Returns:
- a reference to the socket object
- Connection methods
- - (BOOL) close
- Close the connection to the ftp server
- Returns:
- success
- - (BOOL) open :(id <DSocketAddressable>) server
- Open the FTP client
- Parameters:
- server - the address of the server
- Returns:
- success
- Sending and receiving messages
- - (int) receiveResponse
- Receive a response from the server
- Returns:
- the first digit of the last response code (or -1)
- - (BOOL) sendCommand :(const char *) command :(const char *) parameters
- Send a command to the server
- Parameters:
- command - the command to be sent
parameters - the parameters of the command (or NULL)
- Returns:
- success
- FTP methods
- - (BOOL) appendASCII :(const char *) filename :(id <DTextReadable>) file
- Store ASCII on the ftp server, appending an already existing file
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) appendBinary :(const char *) filename :(id <DDataReadable>) file
- Store a binary file on the ftp server, appending an already existing file
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) changeCurrentDirectory :(const char *) directory
- Change the current directory
- Parameters:
- directory - the directory
- Returns:
- success
- - (BOOL) changeCurrentToParent
- Change the current directory to the parent directory
- Returns:
- success
- - (BOOL) delete :(const char *) filename
- Send the delete file to the ftp server
- Parameters:
- filename - the name of the file
- Returns:
- success
- - (BOOL) getWorkingDirectory
- Send the request for the current working directory to the ftp server.
Use 'directory' method for the directory name in the response.
- Returns:
- success
- - (BOOL) help :(const char *) key
- Send the request for help to the ftp server
- Parameters:
- key - the key for the help (or NULL)
- Returns:
- success
- - (BOOL) list :(const char *) name :(DList *) list
- Send the request for a list to the ftp server. If the list is not
nil, the received names will be stored in the list. If it is nil, the
method processListLine will be called for every received list line.
- Parameters:
- name - the directory or filename (or NULL)
list - the list to store the received info (or nil)
- Returns:
- success
- - (BOOL) login :(const char *) user :(const char *) password :(const char *) account
- Do a login on the ftp server
- Parameters:
- user - the user name (or NULL)
password - the password for the user (or NULL)
account - the account of the user (or NULL)
- Returns:
- success
- - (BOOL) makeDirectory :(const char *) directory
- Send the make directory command to the ftp server.
Use 'directory' method for the name of the directory in the response.
- Parameters:
- directory - the directory name
- Returns:
- success
- - (BOOL) mount :(const char *) directory
- Mount a different file system
- Parameters:
- directory - the directory of the file system
- Returns:
- success
- - (BOOL) nameList :(const char *) directory :(DList *) list
- Send the request for a name list to the ftp server. If the list is not
nil, the received names will be stored in the list. If it is nil, the
method processListLine will be called for every received list line.
- Parameters:
- directory - the directory name (or NULL)
list - the list to store the received names (or nil)
- Returns:
- success
- - (BOOL) noop
- Send the request for noop to the ftp server
- Returns:
- success
- - (BOOL) overwriteASCII :(const char *) filename :(id <DTextReadable>) file
- Store ASCII on the ftp server, replacing an already existing file
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) overwriteBinary :(const char *) filename :(id <DDataReadable>) file
- Store a binary file on the ftp server, replacing an already existing file
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) quit
- Send the QUIT command to the ftp server (and close the connnection)
- Returns:
- success
- - (BOOL) reinitialize
- Reinitialize the connection (note: continu with login)
- Returns:
- success
- - (BOOL) removeDirectory :(const char *) directory
- Send the remove directory command to the ftp server
- Parameters:
- directory - the directory name
- Returns:
- success
- - (BOOL) rename :(const char *) oldName :(const char *) newName
- Send the rename command
- Parameters:
- oldName - the old filename
newName - the new filename
- Returns:
- success
- - (BOOL) retrieveASCII :(const char *) filename :(id <DTextWritable>) file
- Retrieve ASCII from the ftp server. This method supports two ways of data
receiving. If the file parameter is not nil, the ASCII data is written to
the TextWritable; if the file parameter is nil, the data is written by
calling the method setASCIIData, which should be overridden.
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (if nil use setAsciiData)
- Returns:
- success
- - (BOOL) retrieveBinary :(const char *) filename :(id <DDataWritable>) file
- Retrieve binary data from the ftp server. This method supports two ways of
data receiving. If the file parameter is not nil, the binary data is written
to the DataWritable; if the file parameter is nil, the data is written by
calling the method setBinaryData, which should be overridden.
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (if nil use setAsciiData)
- Returns:
- success
- - (BOOL) sendListCommand :(const char *) command :(const char *) parameter :(DList *) list
- Send a list commando (LIST or NLST) (private)
- Parameters:
- command - the command to be sent
parameter - the parameter (or NULL)
list - the list to store the information (or nil)
- Returns:
- success
- - (id <DSocketAddressable>) sendPort
- Send the PORT/EPTR commando to the ftp server
- Returns:
- a reference to the socket address received from the server (or nil)
- - (BOOL) siteParameter :(const char *) parameter
- Send the request for site parameters to the ftp server
- Parameters:
- parameter - the parameter
- Returns:
- success
- - (BOOL) state
- Send the request for status to the ftp server
- Returns:
- success
- - (BOOL) storeASCII :(const char *) command :(const char *) filename :(id <DTextReadable>) file
- Store ASCII on the ftp server. This method supports two ways of data
feeding. If the file parameter is not nil, the ASCII data is read from
the TextReadable; if it is nil, the data is read by calling the method
getASCIIData, which should be overridden.
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (if nil then use getAsciiData)
- Returns:
- success
- - (BOOL) storeASCIIUnique :(id <DTextReadable>) file
- Store ASCII file with a filename that is unique on the server
- Parameters:
- file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) storeBinary :(const char *) command :(const char *) filename :(id <DDataReadable>) file
- Store Binary data on the ftp server. This method supports two ways of data
feeding. If the file parameter is not nil, the binary data is read from
the DataReadable; if it is nil, the data is read by calling the method
getBinaryData, which should be overridden.
- Parameters:
- filename - the (path and) name of the file on the server
file - the (opened) file (if nil then use getBinaryData)
- Returns:
- success
- - (BOOL) storeBinaryUnique :(id <DDataReadable>) file
- Store a binary file with a filename that is unique on the server
- Parameters:
- file - the (opened) file (or nil)
- Returns:
- success
- - (BOOL) systemInfo
- Send the request for system information to the ftp server
- Returns:
- success
- - (BOOL) transferASCII
- Use ASCII during data transfer
- Returns:
- success
- - (BOOL) transferBinary
- Use binary during data transfer
- Returns:
- success
- Data feeders
- - (DText *) getASCIIData
- Get ASCII data during an ASCII transfer (to be overridden)
- Returns:
- a (new) text string with ASCII data to be stored (without CR and/or LF) (or nil for done)
- - (DData *) getBinaryData :(int) bufferSize
- Get binary data during an binary transfer (to be overridden)
- Parameters:
- bufferSize - the size of the buffer
- Returns:
- a (new) data string with data to be stored (or nil for done)
- Data savers
- - (void) setASCIIData :(const char *) cstring
- Set ASCII data during an ASCII retrieve (to be overridden)
- Parameters:
- cstring - the string with the ASCII data (no end of line)
- - (void) setBinaryData :(const unsigned char *) data :(unsigned long) length
- Set binary data during an binary retrieve (to be overridden)
- Parameters:
- data - the data
length - the length of the data
- Process responses
- - (void) processListLine :(const char *) line
- Process the receiving of list information (to be overridden)
- Parameters:
- line - one line of the list information
- Returns:
- none
- - (void) processResponse150 :(DText *) response
- Process the 150 response (the byte size)
- Parameters:
- response - the response text
- Returns:
- none
- - (void) processResponse227 :(DText *) response
- Process the 227 response (the inet address)
- Parameters:
- response - the response text
- Returns:
- none
- - (void) processResponse229 :(DText *) response
- Process the 229 response (the inet address for IPv6)
- Parameters:
- response - the response text
- Returns:
- none
- - (void) processResponse257 :(DText *) response
- Process the 257 response (the directory name)
- Parameters:
- response - the response text
- Returns:
- none
- - (void) processResponse :(int) code :(const char *) response
- Process the receiving of a response (to be overridden)
- Parameters:
- code - the response code 1xx - 5xx
response - the response text
- Returns:
- none
generated 05-Nov-2007 by ObjcDoc 3.0.0