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 _seterrno (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 the seek was successful. Discard any effects of the ungetc function,
44 * and clear the end-of-file indicator. Otherwise set the error indicator
45 * on the stream, and return -1. We will check for >= 0 here, because that
46 * saves some code, and we don't have files with 2 gigabytes in size
50 f->f_flags &= ~(_FEOF | _FPUSHBACK);
53 f->f_flags |= _FERROR;