Arduino TinyFTP
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
tinyftp::FTPClient< ClientType > Class Template Reference

FTPClient Basic FTP access class which supports directory operations and the opening of files. Each open file or directory listing uses its own FTP session (command and data connection): idle sessions are reused. The files and iterators must not be used after the FTPClient has been destroyed. More...

#include <FTPClient.h>

Inheritance diagram for tinyftp::FTPClient< ClientType >:
tinyftp::FTPSessionProvider

Public Member Functions

 FTPClient (int port=FTP_COMMAND_PORT, bool useType=false)
 
 FTPClient (const FTPClient &)=delete
 
FTPClient & operator= (const FTPClient &)=delete
 
void setUseTypeCommand (bool useType)
 if set to true the BIN and ASCII command are executed as type I or A
 
bool begin (IPAddress remote_addr, const char *user="anonymous", const char *password=nullptr)
 Defines the server details: the sessions are opened on demand.
 
void end ()
 
FTPFile open (const char *filename, FileMode mode=READ_MODE, bool=true)
 
bool mkdir (const char *filepath)
 
bool remove (const char *filepath)
 Delete the file.
 
bool rmdir (const char *filepath)
 Removes a directory.
 
FTPFileIterator ls (const char *path, FileMode mode=READ_MODE)
 Lists all file names in the specified directory.
 
bool binary ()
 Switch to binary mode.
 
bool ascii ()
 Switch to ascii mode.
 
bool type (const char *str)
 Binary or ascii with type command.
 
void setPort (int port)
 
bool abort (CurrentOperation op)
 
int count ()
 Count the connected sessions.
 
int count (CurrentOperation op)
 Count the connected sessions with a specific current operation.
 
FTPSession< ClientType > * idleSession () override
 Provides an idle, connected session: returns nullptr if none is available.
 
FTPSession< ClientType > * openDataSession () override
 

Protected Attributes

FTPSession< ClientType > * sessions [FTP_MAX_SESSIONS] = {nullptr}
 
IPAddress remote_addr
 
const char * userid = nullptr
 
const char * password = nullptr
 
int port
 
bool use_type_command = false
 

Detailed Description

template<class ClientType>
class tinyftp::FTPClient< ClientType >

FTPClient Basic FTP access class which supports directory operations and the opening of files. Each open file or directory listing uses its own FTP session (command and data connection): idle sessions are reused. The files and iterators must not be used after the FTPClient has been destroyed.

Template Parameters
ClientTypeThe type of client to use for command and data connections. It should be a class that implements the Client interface.
Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ FTPClient()

template<class ClientType >
tinyftp::FTPClient< ClientType >::FTPClient ( int  port = FTP_COMMAND_PORT,
bool  useType = false 
)
inline

Default constructor: Provide the client class as template argument e.g. FTPClient<WiFiClient> client;

Member Function Documentation

◆ abort()

template<class ClientType >
bool tinyftp::FTPClient< ClientType >::abort ( CurrentOperation  op)
inline

Abort the indicated operation (e.g., READ_OP, WRITE_OP, LS_OP.) in all sessions. Returns false if no session was found or an abort failed.

◆ end()

template<class ClientType >
void tinyftp::FTPClient< ClientType >::end ( )
inline

Close the sessions by calling QUIT or BYE: open files and listings become invalid

◆ idleSession()

template<class ClientType >
FTPSession< ClientType > * tinyftp::FTPClient< ClientType >::idleSession ( )
inlineoverridevirtual

Provides an idle, connected session: returns nullptr if none is available.

Implements tinyftp::FTPSessionProvider.

◆ mkdir()

template<class ClientType >
bool tinyftp::FTPClient< ClientType >::mkdir ( const char *  filepath)
inline

Create the requested directory hierarchy–if intermediate directories do not exist they will be created.

◆ open()

template<class ClientType >
FTPFile tinyftp::FTPClient< ClientType >::open ( const char *  filename,
FileMode  mode = READ_MODE,
bool  = true 
)
inline

Open a file: the file is closed with close() or when the last copy of it is destroyed. The autoClose parameter is not used any more.

◆ openDataSession()

template<class ClientType >
FTPSession< ClientType > * tinyftp::FTPClient< ClientType >::openDataSession ( )
inlineoverridevirtual

Provides a session with an open data connection which is reserved until the transfer has ended

Implements tinyftp::FTPSessionProvider.


The documentation for this class was generated from the following file: