You can always just use the C++ functions, you know. Aside from that, the functions are slow because you are only buffering tiny chunks of data at a time, and you're casting it to STL strings. I believe Robert wrote buffer functions; do those not work with files? If not, consider using the C functions or writing wrappers around them (they're extremely simple).
FILE *f = fopen("yourfile.bin", "rb"); char buf[512]; while (!feof(f)) { // Until at end of file size_t read = fread(buf, 1, 512, f); // Read at most 512 bytes // process bytes here; `read` bytes were read in total } fclose(f);
I suppose you'll want the existing convenience functions which do things like read integers for you. In that case, I'd recommend just adding a file_bin_read_buffer() that does what the above does for large chunks.
In the future, we will likely offer memory mapping functions for that.
|