![]() |
Network Component
Version 7.3
MDK Middleware for IPv4 and IPv6 Networking
|
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 in FTP server. [interface]. More... | |
void | netFTPs_fclose (void *file) |
Close a file previously open in FTP server. [interface]. More... | |
uint32_t | netFTPs_fread (void *file, uint8_t *buf, uint32_t len) |
Read block of data from a file in FTP server. [interface]. More... | |
uint32_t | netFTPs_fwrite (void *file, const uint8_t *buf, uint32_t len) |
Write block of data to a file in FTP server. [interface]. More... | |
bool | netFTPs_fdelete (const char *fname) |
Delete a file in FTP server. [interface]. More... | |
bool | netFTPs_frename (const char *fname, const char *newname) |
Rename a file or directory in FTP server. [interface]. More... | |
bool | netFTPs_mkdir (const char *path) |
Make a new directory in FTP server. [interface]. More... | |
bool | netFTPs_rmdir (const char *path) |
Remove an empty directory in FTP server. [interface]. More... | |
uint32_t | netFTPs_ffind (uint8_t code, char *buf, uint32_t buf_len, const char *mask) |
Search the file system directory for matching files. [interface]. More... | |
FTP server functions that work with a File System.
All File System Interface functions are located in FTP_Server_FS.c, which will be automatically added to your project's Network folder. The file is preconfigured for the File System Component, so no modifications are required. If you wish to use another type of file system, you need to override these weak procedures with your required functionality.
The following functions are implemented in this module:
void netFTPs_fclose | ( | void * | file | ) |
Close a file previously open in 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 in 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.
uint32_t netFTPs_ffind | ( | uint8_t | code, |
char * | buf, | ||
uint32_t | buf_len, | ||
const char * | mask | ||
) |
Search the file system directory for matching files. [interface].
[in] | code | request type code:
|
[out] | buf | output buffer to write the listing to. |
[in] | buf_len | length of the output buffer in bytes. |
[in] | mask | file mask filter. |
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 buf. The output data must be formatted in the FTP folder listing format.
The argument code specifies the request type:
Code | Request Type |
---|---|
0 | Read file size. |
1 | Read last-modified time of a file. |
2 | List file names only (first call). |
3 | List file directory in extended format (first call). |
4 | List file names only (subsequent call). |
5 | List file directory in extended format (subsequent call). |
The argument buf_len specifies the size of output buffer buf.
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 in 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 in 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 in 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 in 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 in 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 in 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.