Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-03-18 03:30:18

Jonathan Turkanis wrote:

> 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.

Will it also allow to specify end offset. Start offset is not a problem -- I
can always seek the stream. It's the end offset that's problematic.

> 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 ) ;

This looks suitable for my problem.

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at