Arduino TinyFTP
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tinyftp::FTPFile Class Reference

FTPFile A single file which supports read and write operations. This class is implemented as an Arduino Stream and therefore provides all corresponding functionality. More...

#include <FTPFile.h>

Inheritance diagram for tinyftp::FTPFile:

Public Member Functions

 FTPFile (FTPSessionProvider *provider, FTPBasicAPI *api, const char *name, FileMode mode)
 
size_t write (uint8_t data) override
 
size_t write (const uint8_t *data, size_t len) override
 
size_t write (const char *data, int len)
 
int read () override
 
size_t readBytes (char *buf, size_t nbyte)
 
size_t readBytes (uint8_t *buf, size_t nbyte)
 
size_t readln (char *buf, size_t nbyte)
 Reads a line (w/o the end of line character)
 
int peek () override
 
int available () override
 
void flush () override
 
void reopen ()
 
void close ()
 Ends the transfer (of all copies) and releases the session.
 
bool cancel ()
 Aborts the transfer (of all copies) and releases the session.
 
const char * name () const
 
size_t size () const
 
void setEOL (char *eol)
 
bool isDirectory () const
 
 operator bool ()
 

Protected Member Functions

FTPBasicAPI * dataSession ()
 
FTPBasicAPI * commandSession () const
 
size_t readData (Client *in, uint8_t *buf, size_t len, int terminator)
 
Client * readStream ()
 Starts the download if necessary and provides the data stream.
 
Client * writeStream ()
 Starts the upload if necessary and provides the data stream.
 

Protected Attributes

String file_name
 
const char * eol = "\n"
 
FileMode mode = READ_MODE
 
FTPSessionProvider * provider = nullptr
 
FTPTransferHandle transfer
 
bool has_session = false
 
bool is_open = false
 

Detailed Description

FTPFile A single file which supports read and write operations. This class is implemented as an Arduino Stream and therefore provides all corresponding functionality.

Copies of a file share the same transfer: the transfer is ended when close() is called or when the last copy is destroyed. A file must not be used after the FTPClient which created it has been destroyed.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ FTPFile()

tinyftp::FTPFile::FTPFile ( FTPSessionProvider *  provider,
FTPBasicAPI *  api,
const char *  name,
FileMode  mode 
)
inline

File which uses the provided session (if not null): otherwise a session is requested from the provider when the file is accessed

Member Function Documentation

◆ available()

int tinyftp::FTPFile::available ( )
inlineoverride

Provides the number of bytes which can be read. If no data has arrived yet, we wait up to the timeout (see setTimeout()), so 0 is only returned at the end of the file (or on timeout).

◆ commandSession()

FTPBasicAPI * tinyftp::FTPFile::commandSession ( ) const
inlineprotected

Provides a session for commands (e.g. SIZE): we can not use the session of a running transfer

◆ dataSession()

FTPBasicAPI * tinyftp::FTPFile::dataSession ( )
inlineprotected

Provides the session of the transfer: it is requested from the provider on the first access

◆ readBytes()

size_t tinyftp::FTPFile::readBytes ( uint8_t *  buf,
size_t  nbyte 
)
inline

Reads up to nbyte bytes: returns less at the end of the file (or on timeout)

◆ readData()

size_t tinyftp::FTPFile::readData ( Client *  in,
uint8_t *  buf,
size_t  len,
int  terminator 
)
inlineprotected

Reads up to len bytes until the terminator (if >= 0, it is not stored): stops at the end of the data or on timeout

◆ reopen()

void tinyftp::FTPFile::reopen ( )
inline

Opens the file again after a close(): the next access starts a new transfer


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