From: stephen.hill@... (Steve Hill) Date: 2001-09-20T01:04:24+09:00 Subject: [ruby-talk:21398] Re: Path walking on windows Ed Sinjiashvili wrote in message news:... > Hi, > > I've created a little script that recurses through directories and yields > all files to block. Here it is > > class Dir > def walk (prefix = nil, &walker) > e = self.entries > e.delete "."; e.delete ".." > > if prefix > e.collect! {|x| File.join(prefix, x) } > end > > if block_given? > e.each {|x| > if File.directory? x then > Dir.new(x).walk x, &walker > end > yield x > } > end > > nil > end > end > > Dir.new(".").walk {|p| puts p} > I have a very similar function, but I was wondering if this recursive drop down and then back up through yield statements a good way of doing things? Or is there a better way of returning a block up through arbitary levels of recursion? regards steve