0

I mapped my file to memory using boost::iostreams::mapped_file_source and declared a stream to read the file as boost::iostreams::stream <boost::iostreams::mapped_file_source> streamReader.

It worked fine and I was able to parse the memory mapped file. I used getline to read the entire file and stored certain offsets from the file. While performing this operation I was able to use seekg to seek streamReader to desired position. But once the whole file is read, I cannot seek streamReader to anywhere.

streamReader.fail() returns true. Does streamReader clears the pointer once it reaches the end of file?

Is there some way so that I can go to the desired file offset after reading the entire file?

ThankYou

Jackzz
  • 1,417
  • 4
  • 24
  • 53

1 Answers1

1

I think you should call the clear() method of the stream to reset its state.

See http://www.cplusplus.com/reference/ios/ios/clear/

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • Yes... called clear() and now it works fine. So now I think it was because the failbit was set after reaching the end of file.. Thanks a lot John.. – Jackzz Oct 10 '14 at 09:51