- StreamReader now should be able to deal with files opened in text mode.

# rename StreamReader::_Begin() to InternBegin(), underscore+capital letter is reserved in C++.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@988 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2011-05-07 23:40:36 +00:00
parent f3bd6ac49b
commit af8058498e
1 changed files with 12 additions and 5 deletions

View File

@ -91,7 +91,7 @@ public:
, le(le)
{
ai_assert(stream);
_Begin();
InternBegin();
}
// ---------------------------------------------------------------------
@ -100,7 +100,7 @@ public:
, le(le)
{
ai_assert(stream);
_Begin();
InternBegin();
}
// ---------------------------------------------------------------------
@ -303,8 +303,13 @@ private:
}
// ---------------------------------------------------------------------
void _Begin() {
void InternBegin() {
if (!stream) {
// incase someone wonders: StreamReader is frequently invoked with
// no prior validation whether the input stream is valid. Since
// no one bothers changing the error message, this message here
// is passed down to the caller and 'unable to open file'
// simply describes best what happened.
throw DeadlyImportError("StreamReader: Unable to open file");
}
@ -314,8 +319,10 @@ private:
}
current = buffer = new int8_t[s];
stream->Read(current,s,1);
end = limit = &buffer[s];
const size_t read = stream->Read(current,1,s);
// (read < s) can only happen if the stream was opened in text mode, in which case FileSize() is not reliable
ai_assert(read <= s);
end = limit = &buffer[read];
}
private: