From: Daniel Berger Date: 2011-04-09T01:41:04+09:00 Subject: [ruby-core:35663] Re: [Ruby 1.8 - Bug #4563] Dir#tell broken On Fri, Apr 8, 2011 at 12:29 AM, Eric Wong wrote: > Daniel Berger 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. �ext3 > 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. �spd_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