1
/*-------------------------------------------------------------------------
4
* 64-bit versions of fseeko/ftello()
6
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
11
* $PostgreSQL: pgsql/src/port/fseeko.c,v 1.17 2004-12-31 22:03:53 pgsql Exp $
13
*-------------------------------------------------------------------------
17
* We have to use the native defines here because configure hasn't
20
#if defined(__bsdi__) || defined(__NetBSD__)
28
#include <sys/types.h>
33
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
34
* say off_t is an arithmetic type, but not necessarily integral,
35
* while fpos_t might be neither.
37
* This is thread-safe on BSD/OS using flockfile/funlockfile.
41
fseeko(FILE *stream, off_t offset, int whence)
52
if (fgetpos(stream, &floc) != 0)
55
if (fsetpos(stream, &floc) != 0)
63
if (fsetpos(stream, &offset) != 0)
71
fflush(stream); /* force writes to fd for stat() */
72
if (fstat(fileno(stream), &filestat) != 0)
74
floc = filestat.st_size;
75
if (fsetpos(stream, &floc) != 0)
100
if (fgetpos(stream, &floc) != 0)