filebuf.in_avail

Dietmar Kuehl dietmar_kuehl@yahoo.com
Thu Jun 8 07:14:00 GMT 2000


Hi,

--- Anthony Williams <anthony_w.geo@yahoo.com> wrote:
> OK, so if I open a file that happens to be empty (maybe it was
> created by the open), but don't read from it, am I at EOF, or just
> sitting at the end of the file? I think "just sitting at the end of
> the file", and thus in_avail() should return 0. If I attempt to read
> from it, then I hit EOF, and in_avail() should return -1.

Basically this is correct. However, an attempt to read from a
[currently] empty file might also block and wait for more characters,
eg. if the file happens to be /dev/tty. In this case an EOF is signaled
by the user hitting Ctrl-D which results in 'read()' returning an error
indication.

Actually, it could make sense for 'in_avail()' to return 0 even after
reading beyond EOF because it cannot really tell that the file did not
grow since the last read attempt. That is, -1 would be returned only
if it is known that there will be no more characters eg. because the
file is not open or a previous read attempt returned a fatal error
indication.


=====
< mailto:dietmar_kuehl@yahoo.com >
< http://www.dietmar-kuehl.de/ >

__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com


More information about the Libstdc++ mailing list