FTP server functions that work with a File System. More...
Functions | |
void * | netFTPs_fopen (const char *fname, const char *mode) |
Open a file for reading or writing on FTP server. [interface]. | |
void | netFTPs_fclose (void *file) |
Close a file previously open on FTP server. [interface]. | |
uint32_t | netFTPs_fread (void *file, uint8_t *buf, uint32_t len) |
Read block of data from a file on FTP server. [interface]. | |
uint32_t | netFTPs_fwrite (void *file, const uint8_t *buf, uint32_t len) |
Write block of data to a file on FTP server. [interface]. | |
bool | netFTPs_fdelete (const char *fname) |
Delete a file on FTP server. [interface]. | |
bool | netFTPs_frename (const char *fname, const char *newname) |
Rename a file or directory on FTP server. [interface]. | |
bool | netFTPs_mkdir (const char *path) |
Make a new directory on FTP server. [interface]. | |
bool | netFTPs_rmdir (const char *path) |
Remove an empty directory on FTP server. [interface]. | |
bool | netFTPs_chdir (const char *path) |
Check that the directory exists on FTP server. [interface]. | |
int32_t | netFTPs_ffind (const char *mask, char *fname, uint32_t *fsize, NET_FS_TIME *ftime, bool first) |
Search the file system directory for matching files. [interface]. | |
FTP server functions that work with a File System.
All functions of the File System Interface are located in FTP_Server_FS.c, which is automatically added to the Network folder of your project. The file is preconfigured for the , so no changes are required. If you want to use a different type of file system, you must add a similar file to your project and implement the interface functions yourself.
The following functions are implemented in this module:
bool netFTPs_chdir | ( | const char * | path | ) |
Check that the directory exists on FTP server. [interface].
[in] | path | directory path to check. |
The function netFTPs_chdir verifies that specified directory exists on the FTP server. On success, it returns true. If the file system on the FTP server storage device does not support directories, the function must always return false.
The argument path is a pointer to the directory's name.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
void netFTPs_fclose | ( | void * | file | ) |
Close a file previously open on FTP server. [interface].
[in] | file | pointer to the file to close. |
The function netFTPs_fclose closes the file identified by the file stream pointer in the function argument.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
bool netFTPs_fdelete | ( | const char * | fname | ) |
Delete a file on FTP server. [interface].
[in] | fname | name of the file to delete. |
The function netFTPs_fdelete deletes the file specified by fname from the server.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
int32_t netFTPs_ffind | ( | const char * | mask, |
char * | fname, | ||
uint32_t * | fsize, | ||
NET_FS_TIME * | ftime, | ||
bool | first | ||
) |
Search the file system directory for matching files. [interface].
[in] | mask | file mask filter. |
[out] | fname | buffer to write filename to.
|
[out] | fsize | pointer to where to return the file size.
|
[out] | ftime | pointer to where to return the created or last modified time.
|
[in] | first | find first file. |
The function netFTPs_ffind searches the File System directory for files matching the specified mask filter mask. Matching file information is stored to the output buffer fname, fsize and ftime. The output data is then processed in FTP server and formatted in the FTP folder listing format.
The argument fname is a pointer to a buffer, where the file name is going to be stored. If this argument is NULL, the file name is not requested and is not saved.
The argument fsize is a pointer to where the file size is going to be stored. If this argument is NULL, the file size is not requested and is not saved.
The argument ftime is a pointer to a structure, that will receive the last modification time of a file. If this argument is NULL, the last modification time is not requested and is not saved.
The argument first has a value of true when the first file is requested. On all subsequent calls, the argument first has a value of false. It is used to initialize the file search engine in the File System Component.
This function returns the following values:
Return Value | Description |
---|---|
NET_FS_ATTR_FILE | The entry found is a file |
NET_FS_ATTR_DIRECTORY | The entry found is a directory |
0 | No entry found |
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
void * netFTPs_fopen | ( | const char * | fname, |
const char * | mode | ||
) |
Open a file for reading or writing on FTP server. [interface].
[in] | fname | name of the file to open. |
[in] | mode | type of access:
|
The function netFTPs_fopen opens a file for reading or writing.
The argument fname specifies the name of the file to open.
The argument mode defines the type of access permitted for the file. The argument can have one of the following values:
Mode | Description |
---|---|
"rb" | Opens the file for reading. If the file does not exist, fopen fails. |
"wb" | Opens an empty file for writing if the file does not exist. If the file already exists, its contents are cleared. |
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
uint32_t netFTPs_fread | ( | void * | file, |
uint8_t * | buf, | ||
uint32_t | len | ||
) |
Read block of data from a file on FTP server. [interface].
[in] | file | pointer to the file to read from. |
[out] | buf | block of memory to write data to. |
[in] | len | length of data to read in bytes. |
The function netFTPs_fread reads len bytes from the file file stream pointer specified in the function argument.
The argument buf is a pointer to the buffer where the function stores the read data.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
bool netFTPs_frename | ( | const char * | fname, |
const char * | newname | ||
) |
Rename a file or directory on FTP server. [interface].
[in] | fname | old name to rename from. |
[in] | newname | new name to rename to. |
The function netFTPs_frename renames a file specified by fname to newname on the server.
The argument fname must be the name of an existing file.
The argument newname must be a valid file name that does not exist in the scope.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
uint32_t netFTPs_fwrite | ( | void * | file, |
const uint8_t * | buf, | ||
uint32_t | len | ||
) |
Write block of data to a file on FTP server. [interface].
[in] | file | pointer to the file to write to. |
[in] | buf | block of memory to be written. |
[in] | len | length of data to write in bytes. |
The function netFTPs_fwrite writes a block of data to the file identified by the file stream pointer.
The argument buf points to the buffer containing the data that is to be written to the file.
The argument len specifies the number of bytes to write to the file.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
bool netFTPs_mkdir | ( | const char * | path | ) |
Make a new directory on FTP server. [interface].
[in] | path | directory path to create. |
The function netFTPs_mkdir creates a new directory on the FTP server for file storage. On success, it returns true.
The argument path is a pointer to the directory's name.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.
bool netFTPs_rmdir | ( | const char * | path | ) |
Remove an empty directory on FTP server. [interface].
[in] | path | directory path to remove. |
The function netFTPs_rmdir deletes a directory on the FTP server. On success, it returns true.
The argument path is a pointer to the directory's name.
The function interfaces to the File System Component and will be called by the Network Component automatically. If another file system will be used, refer to the reference implementation in the FTP_Server_FS.c module.