Fix not handling failbit/badbit in ifstream (Bug #1355)

deque
scrawl 10 years ago
parent b470596206
commit a0bff03560

@ -32,6 +32,9 @@ namespace Translation
boost::filesystem::ifstream stream (
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())
throw std::runtime_error ("failed to open translation file: " + fileName);
@ -41,6 +44,7 @@ namespace Translation
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;
while (!stream.eof())
{

Loading…
Cancel
Save