Real time embedded FreeRTOS RSS feed 
Homepage FreeRTOS+ Products FreeRTOS Labs Support Forum Contact / Enquiries

f_getc()

[FreeRTOS Embedded File System API]

header_file.h
int f_getc( F_FILE *pxFileHandle );
		

Reads a single byte from the current read/write position of an open FAT file. The current file position is incremented by one.

A file can only be read if it was opened with one of the following option strings: "r", "r+", "w+" or "a+" (see f_open()).

Parameters:

pxFileHandle   The handle of the file from which a character is being read. The handle is returned by the call to f_open() used to originally open the file.

Returns:
-1   A character was not read from the file.

Any other value   The character that was read from the file.

See also

f_read().

Example usage:


void vSampleFunction( char *pcFileName, char *pcBuffer, long lBufferSize )
{
F_FILE *pxFile;
long lBytesRead;
int iReturnedByte;

    /* Read the file specified by the pcFileName parameter. */
    pxFile = f_open( pcFileName, "r" );

    /* Read the number of bytes specified by the lBufferSize parameter. */
    for( lBytesRead = 0; lBytesRead < lBufferSize; lBytesRead++ )
    {
        iReturnedByte = f_getc( pxFile );

        if( iReturnedByte == -1 )
        {
            /* A byte could not be read. */
            break;
        }
        else
        {
            /* Write the byte into the buffer. */
            pcBuffer[ lBytesRead ] = ( char ) iReturnedByte;
        }
    }

    /* Finished with the file. */
    f_close( pxFile );
}
						
Example use of the f_getc() API function


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.