Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem directory_iterator: how to get the last file of a directory ?
From: strasser_at_[hidden]
Date: 2010-03-12 08:36:44


Zitat von "Vial, Florent" <fvial_at_[hidden]>:

> Hi boost-users,
>
> I am using a recursvive function for iterating over a starting path.
> When i finally arrive in a directory that contains no subdirectory
> (what i call a "final" directory), i want to retrieve
> the first and the last file of this directory.

define "first" and "last".

directory iterators are single-pass input iterators, meaning that they
represent no particular order.
if you iterate over the same directory 2 times, you might retrieve the
entries in a different order.

you could e.g. copy the entries to a std::vector using std::copy and
then sort them, choose first and last, etc.


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