Boost logo

Boost :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2004-10-01 03:38:38


Martin wrote:
> Hi Angus,

Hi, Martin. Thanks for your continued feedback.

> Both your solutions will work ofcourse but I think it solves the problem
> in the wrong end.
>
> Why not drop the dependency on fs:directory_iterator and solve the
> problem at the root.
>
> My suggestion is that you create your own iterators.
>
> 1. filtered_directory_iterator. A simple filter that matches leafs in one
> directory only using '*' & '?' only. Filtering can also be on files and
> directories.
>
> filtered_directory_iterator(const path& p, const char* pattern, enum {
> {no_filter, no_files, no_directories, no_devices...} filter);
>
> This would solve all problems with case sensitivity since you pass the
> pattern direct to filesystem (findfirstfile) (glob() is needed for
> posix). It would also be a "cheap" operation for the most common case
> like finding all files in a directory: filtered_directory_iterator(p,
> "*", ~no_files)

An interesting idea and certainly much less work ;-)

However, as I understand it, you're suggesting limiting the wildcards
simply to ensure that the filtered_directory_iterator behaves the same on
posix and windows systems? Of course that is possible, but my suggestion
gives windows users the full power of glob(). Don't you ever search for
things like "[a-d]*.{cxx,hpp}"?

Sorry, but I don't see why such a proposal is an improvement.

Also, how do you limit the wildcards? I take it you don't, but that the
underlying matcher (findfirstfile, glob) will behave differently on
receipt of the same pattern.

> 2. glob_iterator. A regex based iterator which might even recurse down
> directories to find matches. Personally I can't really see the
> application for a regex file search so you know the requirement better
> than I do.

I haven't created a regex-filtering iterator. I have created a
glob-filtering iterator that uses boost::regex as an implementation
detail. Having said that, all the effort in the proposal went into
transforming a true globbing pattern into an equivalent regex. It would be
trivial to create a true regex-filtering iterator, although I don't see
the application either.

The recursion down directories bit is a separate layer that is built on top
of whatever predicate the filter_iterator uses to match the leaves in one
directory.

Regards,
Angus


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