newlib/winsup/mingw/mingwex/fseeko64.c
Danny Smith 81223d017f 2004-06-30 Kees Zeelenberg <kzlg@users.sourceforge.net>
Danny Smith  <dannysmith@users.sourceforge.net>

	* include/stdio.h (fopen64): Add inline function.
	(fseeko64): Add prototype.
	(ftello64): Add inline function.
	* include/io.h (lseek64): Add inline function.
	* include/sys/types (off64_t): Add typedef.
	(fpos64_t): Add typedef.
        * mingwex/fopen64.c: New file.
        * mingwex/fseeko64.c: New file.
        * mingwex/ftello64.c: New file.
        * mingwex/lseek64.c: New file.
	* mingwex/Makefile.in (STDIO_DISTFILES): Add fopen64.c,
	fseeko.64.c, ftello64.c, lseek64.c.
	(STDIO_OBJS): Add fopen64.o, fseeko.64.o, ftello64.o, lseek64.o.

2004-06-30  Danny Smith  <dannysmith@users.sourceforge.net>

	* include/stdio.h (__mingw_fseeko64): Add prototype.
	* mingwex/mingw-fseek.c (__mingw_fseeko64): Add definition.
	(__mingw_fwrite): Handle huge files.
2004-06-30 04:51:18 +00:00

28 lines
562 B
C

#include <stdio.h>
#include <io.h>
#include <errno.h>
int __cdecl
fseeko64 (FILE* stream, off64_t offset, int whence)
{
fpos_t pos;
if (whence == SEEK_CUR)
{
/* If stream is invalid, fgetpos sets errno. */
if (fgetpos (stream, &pos))
return (-1);
pos += (fpos_t) offset;
}
else if (whence == SEEK_END)
pos = (fpos_t) (_filelengthi64 (_fileno (stream)) + offset);
else if (whence == SEEK_SET)
pos = (fpos_t) offset;
else
{
errno = EINVAL;
return (-1);
}
return fsetpos (stream, &pos);
}