fs_fseek()
int fs_fseek (FS_FILE *p_file, long int offset, int origin);
File | Called from | Code enabled by |
---|---|---|
| Application; |
|
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
- If a read or write error occurs, the error indicator shall be set.
- The new file position, measured in bytes form the beginning of the file, is obtained by adding offset to…:
- …0 (the beginning of the file), if whence is
FS_SEEK_SET
; - …the current file position, if whence is
FS_SEEK_CUR
; - …the file size, if whence is
FS_SEEK_END
;
- …0 (the beginning of the file), if whence is
- The end-of-file indicator is cleared.
- If the file position indicator is set beyond the file’s current data…
- …and data is later written to that point, reads from the gap will read 0.
- …the file must be opened in write or read/write mode.