This site required JavaScript
to be enabled. Click here to
view a static menu.
FF_FILE *ff_fopen( const char *pcFile, const char *pcMode );
Opens a file in the embedded FAT file system.
Parameters:
Files are always opened in binary mode.
If the file was opened successfully then a pointer to the file is returned.
If the file could not be opened then NULL is returned and the task's errno is set to indicate the reason. A task can obtain its errno value using the ff_errno() API function.
Example usage:
BaseType_t xCopyFile( char *pcSourceFileName, char *pcDestinationFileName )
{
FF_FILE *pxSourceFile, *pxDestinationFile;
size_t xCount;
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. */
break;
}
}
/* Close the destination file. */
ff_fclose( pxDestinationFile );
}
/* Close the source file. */
ff_fclose( pxSourceFile );
}
}