## f_lseek

The f_lseek functione moves the file read/write pointer of an open file object.

    FRESULT f_lseek (
      FIL* FileObject,   /* Pointer to the file object structure *
      DWORD Offset       /* File offset in unit of byte *
    );

#### Parameters

FileObject
  Pointer to the open file object.
Offset
  Number of bytes where from start of file

#### Return Values

FR_OK (0)
  The function succeeded.
FR_RW_ERROR
  The function failed due to a disk error or an internal error.
FR_NOT_READY
  The disk drive cannot work due to no medium in the drive or any other reason.
FR_INVALID_OBJECT
  The file object is invalid.

#### Description

The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file is extended to the offset and the data in the extended area is undefined. After the function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is less than Offset, any of the followings has been occured.

- In read-only mode, the Offset was clipped in file size.
- The drive gets full during the file extending process.
- There is any error in the FAT structure.

This function is not supported in minimization level of >= 3.

#### Example

        // Move to offset of 5000 from top of the file.
        res = f_lseek(&file, 5000);

        // Forward 3000 bytes
        res = f_lseek(&file, file.fptr + 3000);

        // Rewind 2000 bytes (take care on overflow)
        res = f_lseek(&file, file.fptr - 2000);

        // Move to end of the file
        res = f_lseek(&file, file.fsize);

#### References

`f_open, FIL`

Return