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


[FreeRTOS Embedded File System API]

unsigned char f_seek( F_FILE *pxFileHandle, long lOffset, unsigned char ucWhence );

Moves the current file read/write position in an open FAT file.


pxFileHandle   The handle of the file in which the current file read/write position is being moved. The handle is returned from the call to f_open() used to originally open the file.

lOffset   The byte position (relative to the ucWhence parameter) to which the current file position will be moved.

ucWhence   The absolute position from which the lOffset parameter is relative. Valid values are:

F_SEEK_CUR The current file position.
F_SEEK_END The end of the file.
F_SEEK_SET The beginning of the file.

F_NO_ERROR   The current file read/write position was successfully moved.

Any other value   The current file read/write position was not successfully moved. The returned value holds the error code.

See also


Example usage:

void vSampleFunction( char *pcFileName, char *pcBuffer )
F_FILE *pxFile;

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

    if( pxFile != NULL )
        /* Read one byte from the opened file. */
        f_read( pcBuffer, 1, 1, pxFile );

        /* Move the current file position back to the very start of the file. */
        f_seek( pxFile, 0, F_SEEK_SET );

        /* Read a byte again.  As the file position was moved back to the start
        of the file the byte that is read is the same byte read by the first
        f_read() call. */
        f_read( pcBuffer, 1, 1, pxFile );

        /* This time move the current position to the very end of the file. */
        f_seek( pxFile, -1, F_SEEK_END );

        /* Now the byte read is the last byte in the file. */
        f_read( pcBuffer, 1, 1, pxFile );

        /* Finished with the file, close it. */
        f_close( pxFile );
Example use of the f_seek() 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.