Network Component  Version 7.11.0
MDK Middleware for IPv4 and IPv6 Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
File System Interface

FTP client functions that work with a File System. More...

Functions

void * netFTPc_fopen (const char *fname, const char *mode)
 Open local file for reading or writing in FTP client. [interface]. More...
 
void netFTPc_fclose (void *file)
 Close local file previously open in FTP client. [interface]. More...
 
uint32_t netFTPc_fread (void *file, uint8_t *buf, uint32_t len)
 Read block of data from local file in FTP client. [interface]. More...
 
uint32_t netFTPc_fwrite (void *file, const uint8_t *buf, uint32_t len)
 Write block of data to local file in FTP client. [interface]. More...
 

Description

FTP client functions that work with a File System.

All File System Interface functions are located in FTP_Client_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 add a similar file to your project.

The following functions are implemented in this module:

Function Documentation

void netFTPc_fclose ( void *  file)

Close local file previously open in FTP client. [interface].

Parameters
[in]filepointer to the file to close.
Returns
none.

The function netFTPc_fclose closes the file identified by the file stream pointer.

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_Client_FS.c module.

void * netFTPc_fopen ( const char *  fname,
const char *  mode 
)

Open local file for reading or writing in FTP client. [interface].

Parameters
[in]fnamename of the file to open.
[in]modetype of access:
  • "rb" = opens a file for reading.
  • "wb" = opens a file for writing.
Returns
status information:
  • Pointer to an open file.
  • NULL in case of an error.

The function netFTPc_fopen opens a local file for reading or writing.

The argument mode defines the type of access permitted for the file fname. It can have one of the following values:

ModeDescription
"rb"Opens the file for reading. If the file does not exist, fopen fails.
"wb"Opens an empty file for writing. 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_Client_FS.c module.

uint32_t netFTPc_fread ( void *  file,
uint8_t *  buf,
uint32_t  len 
)

Read block of data from local file in FTP client. [interface].

Parameters
[in]filepointer to the file to read from.
[out]bufblock of memory to write data to.
[in]lenlength of data to read in bytes.
Returns
number of bytes successfully read.

The function netFTPc_fread reads len bytes from the file identified by the file stream pointer in the function argument.

The argument buf is a pointer to the buffer where the function stores the data read from 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_Client_FS.c module.

Note
The function must read len bytes. The FTP client stops reading and closes the file if the return value is less than len bytes.
uint32_t netFTPc_fwrite ( void *  file,
const uint8_t *  buf,
uint32_t  len 
)

Write block of data to local file in FTP client. [interface].

Parameters
[in]filepointer to the file to write to.
[in]bufblock of memory to be written.
[in]lenlength of data to write in bytes.
Returns
number of bytes successfully written.

The function netFTPc_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 be written 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_Client_FS.c module.

Note
The function must write len bytes. The FTP client stops writing, aborts data transfer and closes the FTP session if the return value is less than len bytes.