gzseek

Name

gzseek -- reposition a file-position indicator in a compressed file stream

Synopsis

#include <zlib.h>

z_off_t gzseek(gzFile file, z_off_t offset, int whence);

Description

The gzseek() function shall set the file-position indicator for the compressed file stream file. The file-position indicator controls where the next read or write operation on the compressed file stream shall take place. The offset indicates a byte offset in the uncompressed data. The whence parameter may be one of:

SEEK_SET 

the offset is relative to the start of the uncompressed data.

SEEK_CUR 

the offset is relative to the current positition in the uncompressed data.

Note: The value SEEK_END need not be supported.

If the file is open for writing, the new offset must be greater than or equal to the current offset. In this case, gzseek() shall compress a sequence of null bytes to fill the gap from the previous offset to the new offset.

Return Value

On success, gzseek() shall return the resulting offset in the file expressed as a byte position in the uncompressed data stream. On error, gzseek() shall return -1, and may set the error value for file accordingly.

Errors

On error, gzseek() shall return -1. The following conditions shall always result in an error:

Application Usage (informative)

If file is open for reading, the implementation may still need to uncompress all of the data up to the new offset. As a result, gzseek() may be extremely slow in some circumstances.