
Vladimir Prus wrote:
Hello, I wonder if the iostreams library allows me to get an istream that will read a part of a file. That is: I specify a file, start offset and end offset. The resulting istream begins reading at start offset and returns EOF when it arrives at end offset.
There wil be an offset filter very soon. I first need to implement in-place filters; otherwise the offset filter will make an unnecessary copy of all the data.
I haven't found anything like this in the docs and I also don't know if such functionality makes sense for the library. I just need to read individual members of Unix static archives (.a files) and wanted to know if the library can help here. If not, I'll just read the data into strstream.
Also: the POSIX mmap call allows one to specify start and end offset. However, the mapped_file_source does not allow to specify that, and documentation does not clearly explain why one would want to use that class at all.
It looks like the docs are over-simplified. Looking at the source I see the following constructors: mapped_file_source( const std::string& path, size_type length = max_length, boost::intmax_t offset = 0 ); mapped_file_sink( const std::string& path, size_type length = max_length, boost::intmax_t offset = 0 ) ; mapped_file( const std::string& path, ios::openmode mode = ios::in | ios::out, size_type length = max_length, boost::intmax_t offset = 0 ) ; Also, someone sent me a version of mapped_file with a lot more functionality, but I haven't intergrated it yet. Best Regards, Jonathan