- 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-9d2fd5bffc1fpull/1/head
parent
f3bd6ac49b
commit
af8058498e
|
@ -91,7 +91,7 @@ public:
|
||||||
, le(le)
|
, le(le)
|
||||||
{
|
{
|
||||||
ai_assert(stream);
|
ai_assert(stream);
|
||||||
_Begin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
, le(le)
|
, le(le)
|
||||||
{
|
{
|
||||||
ai_assert(stream);
|
ai_assert(stream);
|
||||||
_Begin();
|
InternBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
@ -303,8 +303,13 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
void _Begin() {
|
void InternBegin() {
|
||||||
if (!stream) {
|
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");
|
throw DeadlyImportError("StreamReader: Unable to open file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,8 +319,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
current = buffer = new int8_t[s];
|
current = buffer = new int8_t[s];
|
||||||
stream->Read(current,s,1);
|
const size_t read = stream->Read(current,1,s);
|
||||||
end = limit = &buffer[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:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue