Bitwise IO

  • The basic workflow for writing bytes to disk is as follows:

    1. Write bytes to buffer, one byte at a time
    2. Once the buffer is full, write the entire buffer to disk and clear the buffer (i.e., "flush" the buffer)
    3. Repeat
  • Similarly, the basic workflow for reading bytes from disk is as follows:

    1. Read enough bytes from disk to fill the entire buffer (i.e., "fill" the buffer)
    2. Read bytes from buffer, one byte at a time, until the buffer is empty
    3. Repeat
  • If we have no more data to write into the byte buffer, but the buffer haven't been full: flush the buffer

  • If we have no more data from file to put in the bit buffer: pad the data in bit buffer with zeros

*

REFERENCE: Stepik 7.4

results matching ""

    No results matching ""