void flush() { if (!m_open) return; size_t n; if ((n = m_buf.size()) > 0) { m_file.write(m_buf.read(n), n); m_buf.crunch(); } }
/// read portion of file into internal buffer /// if a_crunch == true, crunch buffer before reading bool read(bool a_crunch = true) { if (!m_open || !m_file.is_open()) return false; if (a_crunch) m_buf.crunch(); while (true) { BOOST_ASSERT(m_buf.capacity() > 0); m_file.read(m_buf.wr_ptr(), m_buf.capacity()); int n = m_file.gcount(); if (n == 0) { if (m_file.good()) continue; if (m_file.eof()) return false; // this should never happen since we have set badbit throw io_error(errno, "Unexpected error reading ", m_fname); } m_buf.commit(n); return true; } }