Use std::istream::read instead of readsome

According to the docs
(http://www.cplusplus.com/reference/iostream/istream/readsome/)
readsome would also set state flag eofbit, but apparently I'm
misinterpreting it.  Anyway, using read() and then gcount()
to get the number of bytes does work.
This commit is contained in:
Aleric Inglewood
2012-11-14 18:37:44 +01:00
parent e307df79a1
commit b7af32bee3

View File

@@ -136,7 +136,7 @@ class FileInjector : public Injector
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
{
llifstream fstream(mFilename, std::iostream::binary | std::iostream::out);
llifstream fstream(mFilename, std::ios::binary);
if (!fstream.is_open())
throw AICurlNoBody(llformat("Failed to open \"%s\".", mFilename.c_str()));
LLBufferStream ostream(channels, buffer.get());
@@ -149,7 +149,8 @@ class FileInjector : public Injector
#endif
while (fstream)
{
std::streamsize len = fstream.readsome(tmpbuf, sizeof(tmpbuf));
fstream.read(tmpbuf, sizeof(tmpbuf));
std::streamsize len = fstream.gcount();
if (len > 0)
{
ostream.write(tmpbuf, len);