lseek Function

Move a file pointer to a specified location.

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

Include

<unistd.h>

Prototype

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

Arguments

handle
handle (file descriptor) referring to an opened file
offset
the number of characters from the origin
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.

Remarks

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>):
Origin  
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

lseek.c