delorie.com/djgpp/doc/libc/libc_535.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

llseek

Syntax

 
#include <unistd.h>

offset_t llseek(int fd, offset_t offset, int whence);

Description

This function moves the file pointer for fd according to whence:

SEEK_SET

The file pointer is moved to the offset specified.

SEEK_CUR

The file pointer is moved relative to its current position.

SEEK_END

The file pointer is moved to a position offset bytes from the end of the file. The offset is usually nonpositive in this case.

offset is of type long long, thus enabling you to seek with offsets as large as ~2^63 (FAT16 limits this to ~2^31; FAT32 limits this to 2^32-2).

Return Value

The new offset is returned. Note that due to limitations in the underlying DOS implementation the offset wraps around to 0 at offset 2^32. -1 means the call failed.

Portability

ANSI/ISO C No
POSIX No

Example

 
long long ret;

ret = llseek(fd, (1<<32), SEEK_SET); /* Now ret equals 0
                                      * (unfortunately). */
ret = llseek(fd, -1, SEEK_CUR); /* Now ret equals 2^32-1 (good!). */
ret = llseek(fd, 0, SEEK_SET); /* Now ret equals 0 (good!). */
ret = llseek(fd, -1, SEEK_CUR); /* Now ret equals 2^32-1 (bad). */


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004