This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: Cygwin B20 - fseek under gcc fails to reposition on text files




> >* Seeking with an offset of 0 relative to any of the origin values.

This means fseek(file, 0, SEEK_SET) or fseek(file, 0, SEEK_END).

> >* Seeking from the beginning of the file with an offset value returned
> >from a call to ftell.

This allows the library to read() through the file instead of seeking,
to compensage for CR/LF conversions.  If you seek from the end of the
file, these rules do not guarantee success.

The problems are usually in ftell(), since with buffered I/O it's
nearly impossible to determine what actual file position corresponds
to a character in the middle of a stdio buffer.  DJGPP could only
solve this problem by having stdio open *all* files as binary, and
managing the conversion after the buffering.