[ ]
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS Labs FreeRTOS+TCP FreeRTOS+FAT FreeRTOS+POSIX Contact / Enquiries


FreeRTOS+FAT is still in the lab
FreeRTOS+FAT is already in use in commercial products and we encourage you to try it yourself. Be aware however that FreeRTOS+FAT was acquired by Real Time Engineers Ltd., and is still being documented and updated to ensure it meets our strict quality standards. Please use the forum for support, or contact us directly if you have a specific business interest.

ff_fseek()

[FreeRTOS+FAT Standard API Reference]

ff_stdio.h
int ff_fseek( FF_FILE *pxStream, int iOffset, int iWhence );
		

Moves the current read/write position of an open file to ( iWhence + iOffset ).

Parameters:

pxStream   The file in which the current read/write position is being updated.

iOffset   An offset (in bytes) from the position set by the iWhence parameter to which the file's current read/write position will be set.

iWhence   The position within the file from which the iOffset value is relative. Valid values for iWhence include:

Value
Description
FF_SEEK_CUR The current file position.
FF_SEEK_END The end of the file.
FF_SEEK_SET The beginning of the file.

Returns:

On success 0 is returned.

If the read/write position could not be moved then -1 is returned and the task's errno is set to indicate the reason. A task can obtain its errno value use the ff_errno() API function.

Example usage:


void vSampleFunction( char *pcFileName, char *pcBuffer )
{
FF_FILE *pxFile;

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

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

        /* Move the current file position back to the very start of the file. */
        ff_fseek( pxFile, 0, FF_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
        ff_fread() call. */
        ff_fread( pcBuffer, 1, 1, pxFile );

        /* This time move the current position to the last byte in the file. */
        ff_fseek( pxFile, -1, FF_SEEK_END );

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

        /* Finished with the file, close it. */
        ff_fclose( pxFile );
    }
}
						
Example use of the ff_fseek() API function


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




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