What is the quickest way to read/write a file, especially large amounts of data? The files in question can be as small as several bytes, or as large as >1GB. The data in the files are of type unsigned char, are contiguous, and are acted upon individually (i.e., read one byte from input_file, do something to that byte, write resulting byte to output_file, repeat).
Reading and writing one byte at a time is simple, but I'd imagine that a billion calls to istream::read and ostream::write is a bit overkill. On the other hand, reading the entire file into memory would probably be a bad idea, too.
Perhaps there's a happy medium? Perhaps there's a better alternative to fstream? Platform independence is not terribly important, though I do need to be able to do this in both Windows and Linux, and I'm willing to make two separate implementations if there's a better platform-dependent way to do it in each.
Any help would be greatly appreciated. Thanks in advance.