[英]How to seek stream pointer of a memory mapped file(using boost)?
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
. 我使用boost::iostreams::mapped_file_source
文件映射到内存,并声明了一个流以将文件读取为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. 我使用getline
读取整个文件,并存储了文件中的某些偏移量。 While performing this operation I was able to use seekg
to seek streamReader to desired position. 在执行此操作时,我能够使用seekg
将streamReader查找到所需位置。 But once the whole file is read, I cannot seek streamReader to anywhere. 但是,一旦读取了整个文件,就无法将streamReader查找到任何地方。
streamReader.fail()
returns true. streamReader.fail()
返回true。 Does streamReader clears the pointer once it reaches the end of file? streamReader是否在到达文件末尾时清除指针?
Is there some way so that I can go to the desired file offset after reading the entire file? 有什么办法可以让我在读取整个文件后转到所需的文件偏移量吗?
ThankYou 谢谢
I think you should call the clear()
method of the stream to reset its state. 我认为您应该调用流的clear()
方法来重置其状态。
See http://www.cplusplus.com/reference/ios/ios/clear/ 参见http://www.cplusplus.com/reference/ios/ios/clear/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.