Boost logo

Boost :

From: Henrik Ravn (henrik_at_[hidden])
Date: 2001-11-19 18:25:34


> > struct file_finder
> > {
> > file_finder(const char* pattern);
> > ~file_finder();
> > typedef const char* const* iterator;
> > operator bool() const;
> > iterator begin();
> > iterator end();
> > private:
> > glob_t glob_;
> > };
> >
>
> It doesn't allow access to file info (size, date/time etc) because
> glob doesn't do this, and you get this easily enough once you have a
> filename. I think something like this needs to be integrated with
> the directory iterator stuff already in boost.
>
> Btw the reason for operator bool is to allow:
>
> if (file_finder finder("*.dat"))
> {
> file_finder::iterator i = finder.begin();
> do
> process_file(*i);
> while (++i != finder.end();
> }
> else
> throw no_files_found;

This could be done without operator bool, by including bool empty()
const and then go:

file_finder finder("*.dat");
if (finder.empty())
        throw no_files_found;
for (file_finder::iterator i = finder.begin(); i != finder.end() ++i)
        process_file(*i);

which I think I like better.

Henrik

>
> Dylan
>
>
>
> Info: http://www.boost.org Unsubscribe:
> <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of
> Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk