lseek Function

Move a file pointer to a specified location.

Attention: This interface function is implemented only by MPLAB XC32 C compilers.




long lseek(int handle, long offset, int origin);


handle (file descriptor) referring to an opened file
the number of characters from the origin
the position from which to start the seek

Return Value

Returns the offset, in characters, of the new position from the beginning of the file. The function returns -1 to indicate an error and sets errno. Appropriate values might be EBADF or EINVAL.


This function is implemented as a stub that must be completed to suite the application.

This helper function is called by the Standard C Library functions fgetpos(), ftell(), fseek(), fsetpos and rewind().

The origin argument may be one of the following values (as defined in <stdio.h>):
SEEK_SET Beginning of file
SEEK_CUR Current position of file pointer
SEEK_END End-of-file

Default Behavior

As distributed, the parameters are passed to the host file system through the simulator. The return value is the value returned by the host file system.

Source File