fs_fseek()

int  fs_fseek (FS_FILE    *p_file,
               long  int   offset,
               int         origin);

File

Called from

Code enabled by

fs_api.c

Application; fs_frewind()

FS_CFG_API_EN

Set file position indicator.

Arguments

p_file

Pointer to a file.

offset

Offset from the file position specified by whence.

origin

Reference position for offset:

FS_SEEK_SET

Offset is from the beginning of the file.

FS_SEEK_CUR

Offset is from the current file position.

FS_SEEK_END

Offset is from the end of the file.

Returned Value

0, if the function succeeds.

-1, otherwise.

Notes/Warnings

  1. If a read or write error occurs, the error indicator shall be set.
  2. The new file position, measured in bytes form the beginning of the file, is obtained by adding offset to…:
    1. …0 (the beginning of the file), if whence is FS_SEEK_SET;
    2. …the current file position, if whence is FS_SEEK_CUR;
    3. …the file size, if whence is FS_SEEK_END;
  3. The end-of-file indicator is cleared.
  4. If the file position indicator is set beyond the file’s current data…
    1. …and data is later written to that point, reads from the gap will read 0.
    2. …the file must be opened in write or read/write mode.