|
Arduino TinyFTP
|
CallbackFSClass File system which can be used as storage of the FTPServer: it does not store any files but logs each file operation and reports it to callbacks. Use the CallbackFS object, e.g. More...
#include <CallbackFS.h>
Public Types | |
| enum | Operation { Open , Close , Exists , Remove , Mkdir , Rmdir , Rename } |
| File operations which are reported to the callback. | |
| using | Callback = std::function< bool(Operation op, const char *path, const char *param)> |
| using | ListCallback = std::function< bool(const char *path, std::vector< CallbackFileInfo > &entries)> |
| using | ReadCallback = std::function< int(const char *path, size_t pos, uint8_t *data, size_t len)> |
| using | WriteCallback = std::function< bool(const char *path, const uint8_t *data, size_t len)> |
Public Member Functions | |
| void | setCallback (Callback callback) |
| Defines the callback which is called for all file operations. | |
| void | setListCallback (ListCallback callback) |
| Defines the callback which provides the directory entries. | |
| void | setReadCallback (ReadCallback callback) |
| Defines the callback which provides the content of the files. | |
| void | setWriteCallback (WriteCallback callback) |
| Defines the callback which receives the content of uploaded files. | |
| CallbackFile | open (const char *path) |
| CallbackFile | open (const char *path, const char *mode) |
| Open with a mode string ("r", "w" or "a") | |
| bool | exists (const char *path) |
| bool | remove (const char *path) |
| bool | mkdir (const char *path) |
| bool | rmdir (const char *path) |
| bool | rename (const char *from, const char *to) |
Static Public Member Functions | |
| static CallbackFSClass & | instance () |
| Provides the single instance which is available as CallbackFS. | |
| static const char * | toString (Operation op) |
| Provides the name of the operation. | |
Protected Member Functions | |
| CallbackFile | openFile (const char *path, const char *mode) |
| bool | report (Operation op, const char *path, const char *param=nullptr) |
| Logs the operation and calls the callback: returns its result. | |
Protected Attributes | |
| Callback | callback |
| ListCallback | listCallback |
| ReadCallback | readCallback |
| WriteCallback | writeCallback |
Friends | |
| class | CallbackFile |
CallbackFSClass File system which can be used as storage of the FTPServer: it does not store any files but logs each file operation and reports it to callbacks. Use the CallbackFS object, e.g.
FTPServer<WiFiServer, CallbackFSClass> ftpServer(21, &CallbackFS);
| using tinyftp::CallbackFSClass::Callback = std::function<bool(Operation op, const char *path, const char *param)> |
Operation callback: path is the file name (rename: the old name); param is the mode ("r", "w" or "a") for open and close, the new name for rename or nullptr
| using tinyftp::CallbackFSClass::ListCallback = std::function<bool( const char *path, std::vector<CallbackFileInfo> &entries)> |
List callback: returns true if the path is a directory and adds its entries
| using tinyftp::CallbackFSClass::ReadCallback = std::function<int(const char *path, size_t pos, uint8_t *data, size_t len)> |
Read callback: copies up to len bytes of the file starting at pos into data and returns the number of bytes (0 at the end of the file). If data is nullptr, it returns the file size (or 0 if unknown) or -1 if the file does not exist.
| using tinyftp::CallbackFSClass::WriteCallback = std::function<bool(const char *path, const uint8_t *data, size_t len)> |
Write callback: receives the next len bytes of the uploaded file. It is called with data == nullptr when the file is opened: return false to reject the upload.