Name

gztell — Returns the starting position for the next read or write operation on compressed file stream file.


Library

Libz.lib


Synopsis

#include <zlib.h>

z_off_t gztell(gzFile file );


Return Value

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


Detailed Description

The gztell() function shall return the starting position for the next read or write operation on compressed file stream file. This position represents the number of bytes from the beginning of file in the uncompressed data.

gztell() is equivalent to gzseek(file, 0L, SEEK_SET).


Examples

To return the starting position for the next read or write operation on compressed file stream file:

#include <stdio.h>
#include <zlib.h>

void Gztell( )
{
Byte *compr, *uncompr;
uLong comprLen = 20*sizeof(int);
uLong uncomprLen = comprLen;
const char hello[] = "hello, hello!";
int len = (int)strlen(hello)+1;
gzFile file;
z_off_t pos;
static const char* myVersion = ZLIB_VERSION;
compr = (Byte*)calloc((uInt)comprLen, 1);
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
compress(compr, &comprLen, (const Bytef*)hello, len);
file = gzopen(fname, "rb");
strcpy((char*)uncompr, "garbage");

gzread(file, uncompr, (unsigned)uncomprLen);
pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos)
{
printf("error");
}
gzclose(file);
free(compr);
free(uncompr);
}

Errors

On error, gztell() shall return -1, indicating that file is NULL, or does not represent an open compressed file stream.


Feedback

For additional information or queries on this page send feedback

© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.

Top