Random File IO

I just finished reading the following tutorial:

I was hoping someone could point me in the right direction, on where I can learn about efficiently reading and writing random file io, and how that translates to actual hardware requests.

For example, I'm guessing C++ is buffering a lot of input/output and attempting to batch the requests -- but I want full control over how the hardware behaves so I can toy with some test programs.

Last edited on
It isn’t just C++ doing magic buffering — the underlying OS will also buffer.

Don’t try to get around it. If you want to make sure that the OS has been properly instructed to synchronize output to disk, perform a flush. Otherwise, assume that the system works as described to you by the language.

If you want more direct file access, consider using memory-mapped file I/O. Boost lets you do it in a platform-friendly way. Two examples:

Keep in mind, though, that memory-mapping does not imply instant I/O to disk — it is still up to the OS when to do it.

Good luck!
Registered users can post here. Sign in or register to post.