f_seek


Use this function to move the stream position in the target file. The file must be open.

Format

unsigned char f_seek (
    F_FILE *   filehandle,
    long       offset, 
    long       whence )

Arguments

Argument Description Type
filehandle The file handle. F_FILE *
offset The relative byte position according to whence. long
whence

Where to calculate offset from:

  • F_SEEK_CUR – Current position of file pointer.
  • F_SEEK_END – End of file.
  • F_SEEK_SET – Beginning of file.
long

Return values

Return value Description
F_NOERR Successful execution.
Else See Error Codes.

Example

int myreadfunc( char *filename, char *buffer, long buffsize )
{
    F_FILE *file = f_open( filename, "r" );
    f_read( buffer, 1, 1, file ); /* Read one byte */
    f_seek( file, 0, SEEK_SET );
    f_read( buffer, 1, 1, file ); /* Read the same byte */
    f_seek( file,-1, SEEK_END );
    f_read( buffer, 1, 1, file ); /* Read the last byte */
    f_close( file );
    return 0;
}