Set the file pointer associated with descriptor according to whence.

Synopsis

Declared in <bdls_filesystemutil.h>

static
Offset
seek(
    FileDescriptor descriptor,
    Offset offset,
    int whence);

Description

Set the file pointer associated with the specified descriptor (used by calls to the read and write system calls) according to the specified whence behavior: ` * If 'whence' is e_SEEK_FROM_BEGINNING, set the pointer to 'offset' bytes from the beginning of the file. * If 'whence' is e_SEEK_FROM_CURRENT, advance the pointer by 'offset' bytes * If 'whence' is e_SEEK_FROM_END, set the pointer to 'offset' bytes beyond the end of the file. ` Return the new location of the file pointer, in bytes from the beginning of the file, on success; and ‐1 otherwise. The effect on the file pointer is undefined unless the file is on a device capable of seeking. Note that seek does not change the size of the file if the pointer advances beyond the end of the file; instead, the next write at the pointer will increase the file size.

Return Value

the new file‐pointer location on success, and ‐1 otherwise

Parameters

Name

Description

descriptor

file descriptor whose file pointer is set

offset

byte offset applied according to whence

whence

starting point for the seek operation

Created with MrDocs