• Advertisement
Sign in to follow this  

File Streams

This topic is 3703 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

Hi everyone, I'm creating a lump file class and I need to know more about std::ifstream. When I use the constructor that auto calls open or open itself does it load the entire file into memory? Also, how can I read from a particular number of bytes into the file?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by ganbree
When I use the constructor that auto calls open or open itself does it load the entire file into memory?

This depends on the implementation and the size of the file being opened, but generally, no. It'll read from the file as necessary as you call operations on the file stream.
Quote:

Also, how can I read from a particular number of bytes into the file?

Did you try the read() member function?

Share this post


Link to post
Share on other sites
Thank you. That complicates things.

However, read() does not let me set from where in the file to read. I've found fstream::seekg() from my DerivedClass::GetFileSize (copied from an earlier project), I think thats the answer.

Case solved. ~ish

Share this post


Link to post
Share on other sites
Quote:
Original post by ganbree
Thank you. That complicates things.

However, read() does not let me set from where in the file to read. I've found fstream::seekg() from my DerivedClass::GetFileSize (copied from an earlier project), I think thats the answer.

Case solved. ~ish


C++ STL Reference

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement