From b7af32bee38b598a0c54075c318e1fb672ffe0b2 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 14 Nov 2012 18:37:44 +0100 Subject: [PATCH] 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. --- indra/llmessage/llhttpclient.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index cbe6e9252..61a5cc50f 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -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);