[FreeRTOS+FAT Standard API Reference]
FF_FILE *ff_fopen( const char *pcFile, const char *pcMode );
Opens a file in the embedded FAT file system.
A pointer to a standard null terminated C string that holds
the name of the file being opened. The string
can include a relative path.
A string that sets the mode in which the file is opened.
Valid strings include:
Files are always opened in binary mode.
If the file was opened successfully then a pointer to the file is returned.
BaseType_t xCopyFile( char *pcSourceFileName, char *pcDestinationFileName )
FF_FILE *pxSourceFile, *pxDestinationFile;
uint32_t ucBuffer[ 50 ];
/* Open the source file in read only mode. */
pxSourceFile = ff_fopen( pcSourceFileName, “r” );
if( pxSourceFile != NULL )
/* Create or overwrite a writable file. */
pxDestinationFile = ff_fopen( pcDestinationFileName, “w+” );
if( pxDestinationFile != NULL )
for( ;; )
/* Read sizeof( ucBuffer ) bytes from the source file into a buffer. */
xCount = ff_fread( ucBuffer, 1, sizeof( ucBuffer ), pxSourceFile );
/* Write however many bytes were read from the source file into the
destination file. */
ff_fwrite( ucBuffer, xCount, 1, pxDestinationFile );
if( xCount < sizeof( ucBuffer ) )
/* The end of the flie was reached. */
/* Close the destination file. */
ff_fclose( pxDestinationFile );
/* Close the source file. */
ff_fclose( pxSourceFile );
Example use of the ff_fopen() API function to open or create a file