Esempio n. 1
0
 /// 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;
     }
 }
Esempio n. 2
0
 void commit(size_t n) { m_buf.commit(n); }