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 stdioGET_ERRNO()
API function.
Example usage:
void vSampleFunction( char *pcFileName, char *pcBuffer )
{
FF_FILE *pxFile;
pxFile = ff_fopen( pcFileName, "r" );
if( pxFile != NULL )
{
ff_fread( pcBuffer, 1, 1, pxFile );
ff_fseek( pxFile, 0, FF_SEEK_SET );
ff_fread( pcBuffer, 1, 1, pxFile );
ff_fseek( pxFile, -1, FF_SEEK_END );
ff_fread( pcBuffer, 1, 1, pxFile );
ff_fclose( pxFile );
}
}
Example use of the ff_fseek() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.