4 * Christian Groessler, 2000-08-07
5 * Ullrich von Bassewitz, 2004-05-12
17 /*****************************************************************************/
19 /*****************************************************************************/
23 int __fastcall__ fseek (register FILE* f, long offset, int whence)
27 /* Is the file open? */
28 if ((f->f_flags & _FOPEN) == 0) {
29 _errno = EINVAL; /* File not open */
33 /* If we have a pushed back character, and whence is relative to the
34 * current position, correct the offset.
36 if ((f->f_flags & _FPUSHBACK) && whence == SEEK_CUR) {
41 res = lseek(f->f_fd, offset, whence);
43 /* If we had an error, set the error indicator on the stream, and
44 * return -1. We will check for < 0 here, because that saves some code,
45 * and we don't have files with 2 gigabytes in size anyway:-)
48 f->f_flags |= _FERROR;
52 /* The seek was successful. Discard any effects of the ungetc function,
53 * and clear the end-of-file indicator.
55 f->f_flags &= ~(_FEOF | _FPUSHBACK);