• Advertisement

Archived

This topic is now archived and is closed to further replies.

Opening files

This topic is 6728 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
I'm just wondering how most of you open files, I know how I just want to see what the fastest and most common way is.

Share this post


Link to post
Share on other sites
If you're using Windows and you want speed the Win32 API functions CreateFile, ReadFile, WriteFile should be fastest. All the other options (fopen/istream/whatever) call on the services of these functions at some point. The only thing to watch is that they aren't buffered. So if you make lots of short reads or writes it will go SLOOOOOWWWWWW!

If I want speed and buffering, I use CreateFileMapping and MapViewOfFile. These allocate a file into the process's address space so you can access it through a pointer. Its kind if like turning the file into a second swapfile.

Share this post


Link to post
Share on other sites

  • Advertisement