On Fri, Apr 8, 2011 at 12:29 AM, Eric Wong <normalperson / yhbt.net> wrote:
> Daniel Berger <redmine / ruby-lang.org> wrote:
>> I was expecting "1", in part because of the example from the pickaxe,
>> and also because that's what JRuby returns. OS X 10.4 returns a simple
>> index, too. However, I now see it's not necessarily just a simple
>> index, depending on the platform.
>
> Yes, readdir/telldir aren't guaranteed to have any ordering. =A0ext3
> created with dir_index and ext4 (I think) do this to you, maybe others.
>
> You can search for the spd_readdir LD_PRELOAD from Ted T'so
> to get readdir() to sort by inode like you'd expect. =A0spd_readdir
> can reduce disk seeks if you're iterating through a directory, too.

Unfortunately that would create a dependency on a 3rd party library. I
think it would be nicer to just store the values in an internal array,
and reference that array, instead of the "real" result of Dir#tell.
This would mean modifying Dir#seek as well, but it would certainly be
a nicer interface for people, as I could use Dir#seek to an expected
specific point instead of storing and retrieving the results of
Dir#tell and messing with that. I'm *guessing* that's what JRuby (or
perhaps Java) is doing.

But, whatever. It's not a huge deal. Just mulling it around. :)

Regards,

Dan