forked from teamnwah/openmw-tes3coop
Fix not handling failbit/badbit in ifstream (Bug #1355)
This commit is contained in:
parent
b470596206
commit
a0bff03560
1 changed files with 4 additions and 0 deletions
|
@ -32,6 +32,9 @@ namespace Translation
|
||||||
boost::filesystem::ifstream stream (
|
boost::filesystem::ifstream stream (
|
||||||
dataFileCollections.getCollection (extension).getPath (fileName));
|
dataFileCollections.getCollection (extension).getPath (fileName));
|
||||||
|
|
||||||
|
// Configure the stream to throw exception upon error
|
||||||
|
stream.exceptions ( boost::filesystem::ifstream::failbit | boost::filesystem::ifstream::badbit );
|
||||||
|
|
||||||
if (!stream.is_open())
|
if (!stream.is_open())
|
||||||
throw std::runtime_error ("failed to open translation file: " + fileName);
|
throw std::runtime_error ("failed to open translation file: " + fileName);
|
||||||
|
|
||||||
|
@ -41,6 +44,7 @@ namespace Translation
|
||||||
|
|
||||||
void Storage::loadDataFromStream(ContainerType& container, std::istream& stream)
|
void Storage::loadDataFromStream(ContainerType& container, std::istream& stream)
|
||||||
{
|
{
|
||||||
|
// NOTE: does not handle failbit/badbit. stream must be set up beforehand to throw in these cases.
|
||||||
std::string line;
|
std::string line;
|
||||||
while (!stream.eof())
|
while (!stream.eof())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue