Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS+ Products FreeRTOS Labs Integration Services Contact / Enquiries

f_filelength()

[FreeRTOS Embedded File System API]

header_file.h
long f_filelength( const char * pcFileName );
		

Returns the length of a file in the FAT file system.

Parameters:

pcFileName   The name of the file (with or without a path) being queried. The name is specified as a standard null terminated C string.

Returns:
0   Either:
  • The file does not exist.
  • F_FS_THREAD_AWARE is set to 1 and a file system lock could not be obtained before F_MAX_LOCK_WAIT_TICKS elapsed.

Any other value   The length of the file in bytes.

Example usage:


long lReadFile( char *pcFileName, char *pcBuffer, long lBufferSize )
{
F_FILE *pxFile;
long lFileSize = 0;

    pxFile = f_open( pcFileName, "r" );

    /* Check the file was opened. */
    if( pxFile != NULL )
    {
        /* Obtain the length of the file. */
        lFileSize = f_filelength( pcFileName );

        /* If the contents of the file will fit into the buffer. */
        if( lFileSize <= lBufferSize )
        {
            /* Read the file into the buffer. */
            f_read( pcBuffer, lFileSize, 1, pxFile );
            f_close( pxFile );
        }
    }

    return lFileSize;
}
						
Example use of the f_filelength() API function


[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS+ Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]


Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.