Boost logo

Boost Users :

Subject: Re: [Boost-users] Reading a file in reverse using boost::iostreams
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2019-02-13 20:15:27


On 13/02/2019 04:43, Richard Hodges via Boost-users wrote:
> My solution would be:
>
> 1. memory map the file (either use boost.interprocess or trivially
> hand-roll a few OS calls)
> 2. build an iterator pair (i.e. char *) representing the extent of the
> mapped memory,
> 3. call std::make_reverse_iterator on the iterator pair
> 4. use a standard algorithm

Unless the file is warm cached, this will be slow. I know of no kernel
which performs readbehind, only readahead.

Safer is to do as Gavin suggests, jump to some offset from the maximum
extent, read forwards.

Niall


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net