commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: [io] DirectoryWalker scan order
Date Sat, 20 Oct 2007 04:23:26 GMT
On 10/19/07, Adrian Herscu <bmf1972@fastmail.fm> wrote:
> Hi all,
>
> I have a test that depends on the scanning order of the
> DirectoryWalker#walk method. The (or, my) problem with this method is
> that it depends on the order of the file array returned by the
> File#listFiles method which by definition does not guarantee any
> particular order...
>
> My specific problem is that tests which pass on a Win32 OS fail on a
> *nix OS because of different scanning order :-(
>
> I cannot see any way to make it scan directories in a specific order...
> Both walk methods cannot be overridden (one is private and the other is
> protected and final).
>
> Any reason for this design?

The private walk method is the guts of the DirectoryWalker - if it
could be overriden then it could be done in one of 2 ways - either 1)
just providing different logic (i.e. not calling super.walk()) and in
this case then its better to just do this in completely different
method (e.g. run() ) - or 2) doing something and calling super.walk()
- in this instance there is already a handleDirectoryStart() method
that could be used to achieve the same thing.

> Perhaps in the next release someone will add an additional walk version
> that accepts a sorter...

Guess you mean java.util.Comparator? We could do that, although it may
be confusing since someone may expect all files/directories to be
processed in that order - rather than just the contents of individual
directories to be sorted.

The best thing to do if you want this is to file an enhancement
request using Jira:

http://commons.apache.org/io/issue-tracking.html

Niall

> Adrian.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message