diff --git a/lib/tokenize/src/tokenize/Stream.cpp b/lib/tokenize/src/tokenize/Stream.cpp index e275247..49e1b58 100644 --- a/lib/tokenize/src/tokenize/Stream.cpp +++ b/lib/tokenize/src/tokenize/Stream.cpp @@ -30,14 +30,22 @@ void Stream::read(std::string streamName, std::istream &istream) // Store position of new section m_delimiters.push_back({m_stream.size(), streamName}); - /*istream.seekg(0, std::ios::end); - const auto streamSize = istream.tellg(); - istream.seekg(0, std::ios::beg); + try + { + istream.seekg(0, std::ios::end); + const auto streamSize = istream.tellg(); + istream.seekg(0, std::ios::beg); - const auto startPosition = m_stream.size(); + const auto startPosition = m_stream.size(); - m_stream.resize(m_stream.size() + streamSize);*/ - std::copy(std::istreambuf_iterator(istream), std::istreambuf_iterator(), std::back_inserter(m_stream)); + m_stream.resize(m_stream.size() + streamSize); + std::copy(std::istreambuf_iterator(istream), std::istreambuf_iterator(), m_stream.begin() + startPosition); + } + catch (const std::exception &exception) + { + istream.clear(); + std::copy(std::istreambuf_iterator(istream), std::istreambuf_iterator(), std::back_inserter(m_stream)); + } } ////////////////////////////////////////////////////////////////////////////////////////////////////