From: Trans Date: 2008-08-20T07:53:02+09:00 Subject: Re: Fools Filing On Aug 19, 2:45 am, Michael Morin wrote: > Trans wrote: > > My immediate thought was then, what about Dir, does it support #glob? > > That was immediately followed by, "hey, I never ever use Dir.new". > > That was key. I looked it up: > > > Instance Methods: > >    close, each, path, pos, pos=, read, rewind, seek, tell > > > That's it. I don't even fully understand what all those do. It's > > treating a Dir as an IO object? > > This is wrapping the diropen function from C.  Calling opendir returns a > DIR* (which is similar to a FILE*).  Individual directory entities can > be read one at a time with readdir and the rest just modify the position > indicator. > > Reading them all with glob may not always be appropriate.  On very large > directories (thousands of files), that would be pretty slow and use a > good chunk of RAM. I see. That's good to know actually. These are some cases were I could use this to optimize my code. > > And there's the problem, what we need are "lazy" File and Dir classes > > that delegate to the IO ones, that allow us to do everything we need, > > rather than fussing with all these others. > > > I think I'll throw this together. Anyone else interested? > > Can you give a mockup of what you're talking about? I've been working on it today. I post it up tomorrow. T.