<< Previous | Next >> | |
|
int fat_Seek( FATfile *file, long pos, int whence );
Description
- Positions the internal file position pointer.
fat_Seek()
will allocate clusters to the file if necessary, but will not move the position pointer beyond the original end of file (EOF) unless doing aSEEK_RAW
. In all other cases, extending the pointer past the original EOF will preallocate the space that would be needed to position the pointer as requested, but the pointer will be left at the original EOF and the file length will not be changed. If this occurs, an EOF error will be returned to indicate the space was allocated but the pointer was left at the EOF.Parameters
- file
- Pointer to the file structure of the open file.
- pos
- Position value in number of bytes (may be negative). This value is interpreted according to the third parameter,
whence
.
- whence
- Must be one of the following:
SEEK_SET
-pos
is the byte position to seek, where 0 is the first byte of the file. Ifpos
is less than 0, the position pointer is set to 0 and no error code is returned. If pos is greater than the length of the file, the position pointer is set to EOF and error code-EEOF
is returned.
SEEK_CUR
- seekpos
bytes from the current position. Ifpos
is less than 0 the seek is towards the start of the file. If this goes past the start of the file, the position pointer is set to 0 and no error code is returned. If pos is greater than 0 the seek is towards EOF. If this goes past EOF the position pointer is set to EOF and error code-EEOF
is returned.
SEEK_END
- seek topos
bytes from the end of the file. That is, for a file that is x bytes long, the statement:
- will cause the position pointer to be set at x-1 no matter its value prior to the seek call. If the value of pos would move the position pointer past the start of the file, the position pointer is set to 0 (the start of the file) and no error code is returned. If
pos
is greater than or equal to 0, the position pointer is set to EOF and error code-EEOF
is returned..Return Value
0
: success.
-EIO
: device I/O error.
-EINVAL
:file
,pos
, orwhence
contain invalid values.
-EPERM
: the file is locked or writes are not permitted.
-ENOENT
: the file does not exist.
-EEOF
: space is allocated, but the pointer is left at original EOF.
-ENOSPC
: no space is left on the device to complete the seek.
-EBUSY
: the device is busy (Only if non-blocking).
-EFSTATE
: if file in inappropriate state (Only if non-blocking).Library
- FAT.LIB
See Also
- fat_Open, fat_Read, fat_Write, fat_xWrite
Dynamic C Functions | << Previous | Next >> | rabbit.com |