issue about FileStreamDataStream::eof

Minor issues with the Ogre API that can be trivial to fix
Post Reply
oiram
Halfling
Posts: 87
Joined: Sun Dec 13, 2009 5:06 am

issue about FileStreamDataStream::eof

Post by oiram » Tue Jun 17, 2014 12:42 pm

Ogre use "while(!stream->eof())" to check end of file for serializer.
In "FileStreamDataStream::eof()", it use "return mInStream->eof()". It's not correct!
Further Reading:
http://stackoverflow.com/questions/3712 ... f-the-file
http://stackoverflow.com/questions/6283 ... s-eof-in-c
http://www.parashift.com/c++-faq-lite/i ... d-eof.html

I think "return mInStream->peek() == std::istream::traits_type::eof();" to check EOF is better.
What's your advice? :)
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: issue about FileStreamDataStream::eof

Post by c6burns » Tue Jun 17, 2014 1:09 pm

It's only incorrect if you try to use what came from the read operation that set the eof bit (eg. you read() and you don't call gcount() and you just blindly use the buffer you read into)
0 x

Post Reply