unsigned char f_seek( F_FILE *pxFileHandle, long lOffset, unsigned char ucWhence );
Moves the current file read/write position in an open FAT file.
Parameters:
| pxFileHandle |
The handle of the file in which the current file read/write position
is being moved. The handle is returned from the call to
f_open() used to originally open the file.
|
||||||||
| lOffset |
The byte position (relative to the ucWhence parameter)
to which the current file position will be moved.
|
||||||||
| ucWhence |
The absolute position from which the lOffset parameter is
relative. Valid values are:
|
| F_NO_ERROR |
The current file read/write position was successfully moved.
|
| Any other value |
The current file read/write position was not successfully moved.
The returned value holds the error code.
|
See also
Example usage:
void vSampleFunction( char *pcFileName, char *pcBuffer ) { F_FILE *pxFile; /* Open the file specified by the pcFileName parameter. */ pxFile = f_open( pcFileName, "r" ); if( pxFile != NULL ) { /* Read one byte from the opened file. */ f_read( pcBuffer, 1, 1, pxFile ); /* Move the current file position back to the very start of the file. */ f_seek( pxFile, 0, F_SEEK_SET ); /* Read a byte again. As the file position was moved back to the start of the file the byte that is read is the same byte read by the first f_read() call. */ f_read( pcBuffer, 1, 1, pxFile ); /* This time move the current position to the very end of the file. */ f_seek( pxFile, -1, F_SEEK_END ); /* Now the byte read is the last byte in the file. */ f_read( pcBuffer, 1, 1, pxFile ); /* Finished with the file, close it. */ f_close( pxFile ); } } Example use of the f_seek() API function